Class ListPattern<T>
Defines the pattern matching on a sequence of elements.
public record ListPattern<T> : Pattern<IList<T>>, IEquatable<Pattern>, IEquatable<Pattern<IList<T>>>, IEquatable<ListPattern<T>>
Type Parameters
TThe type of values in the list.
- Inheritance
-
ListPattern<T>
- Implements
- Inherited Members
Constructors
ListPattern(ListPattern<T>)
protected ListPattern(ListPattern<T> original)
Parameters
originalListPattern<T>
ListPattern(ImmutableArray<Pattern<T>>)
Defines the pattern matching on a sequence of elements.
public ListPattern(ImmutableArray<Pattern<T>> Elements)
Parameters
ElementsImmutableArray<Pattern<T>>The elements in the sequence.
Properties
Elements
The elements in the sequence.
public ImmutableArray<Pattern<T>> Elements { get; init; }
Property Value
Empty
Gets the singleton instance of the ReadOnlyListPattern<T>.
public static ListPattern<T> Empty { get; }
Property Value
- ListPattern<T>
EqualityContract
protected override Type EqualityContract { get; }
Property Value
Methods
Deconstruct(out ImmutableArray<Pattern<T>>)
public void Deconstruct(out ImmutableArray<Pattern<T>> Elements)
Parameters
ElementsImmutableArray<Pattern<T>>
Equals(ListPattern<T>?)
public virtual bool Equals(ListPattern<T>? other)
Parameters
otherListPattern<T>
Returns
Equals(Pattern<IList<T>>?)
public override sealed bool Equals(Pattern<IList<T>>? other)
Parameters
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(IList<T>, MatchingContext)
Attempts to match the provided input to the pattern.
public override IMatchNode<IList<T>>? Match(IList<T> input, MatchingContext context)
Parameters
inputIList<T>The input to match.
contextMatchingContextThe context in which to match the pattern to.
Returns
- IMatchNode<IList<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 ==(ListPattern<T>?, ListPattern<T>?)
public static bool operator ==(ListPattern<T>? left, ListPattern<T>? right)
Parameters
leftListPattern<T>rightListPattern<T>
Returns
operator !=(ListPattern<T>?, ListPattern<T>?)
public static bool operator !=(ListPattern<T>? left, ListPattern<T>? right)
Parameters
leftListPattern<T>rightListPattern<T>