Class LiteralPattern<T>
Defines the pattern matching on exact instances of a type.
public record LiteralPattern<T> : Pattern<T>, IEquatable<Pattern>, IEquatable<Pattern<T>>, IEquatable<LiteralPattern<T>>
Type Parameters
TThe type of values to match.
- Inheritance
-
Pattern<T>LiteralPattern<T>
- Implements
-
IEquatable<Pattern<T>>
- Inherited Members
Constructors
LiteralPattern(LiteralPattern<T>)
protected LiteralPattern(LiteralPattern<T> original)
Parameters
originalLiteralPattern<T>
LiteralPattern(T)
Defines the pattern matching on exact instances of a type.
public LiteralPattern(T Value)
Parameters
ValueTThe expected instance of the type.
Properties
EqualityContract
protected override Type EqualityContract { get; }
Property Value
Value
The expected instance of the type.
public T Value { get; init; }
Property Value
- T
Methods
Deconstruct(out T)
public void Deconstruct(out T Value)
Parameters
ValueT
Equals(LiteralPattern<T>?)
public virtual bool Equals(LiteralPattern<T>? other)
Parameters
otherLiteralPattern<T>
Returns
Equals(Pattern<T>?)
public override sealed bool Equals(Pattern<T>? other)
Parameters
otherPattern<T>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
Format(IndentedTextWriter)
Serializes the pattern to a readable string.
public override void Format(IndentedTextWriter writer)
Parameters
writerIndentedTextWriterThe output stream.
GetHashCode()
public override int GetHashCode()
Returns
Match(T, MatchingContext)
Attempts to match the provided input to the pattern.
public override IMatchNode<T>? Match(T input, MatchingContext context)
Parameters
inputTThe input to match.
contextMatchingContextThe context in which to match the pattern to.
Returns
- IMatchNode<T>
When successful, returns the root node of the match tree, otherwise
null.
PrintMembers(StringBuilder)
protected override bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
Operators
operator ==(LiteralPattern<T>?, LiteralPattern<T>?)
public static bool operator ==(LiteralPattern<T>? left, LiteralPattern<T>? right)
Parameters
leftLiteralPattern<T>rightLiteralPattern<T>
Returns
operator !=(LiteralPattern<T>?, LiteralPattern<T>?)
public static bool operator !=(LiteralPattern<T>? left, LiteralPattern<T>? right)
Parameters
leftLiteralPattern<T>rightLiteralPattern<T>