Class ReadOnlyListPattern<T>
Defines the pattern matching on a sequence of elements.
public record ReadOnlyListPattern<T> : Pattern<IReadOnlyList<T>>, IEquatable<Pattern>, IEquatable<Pattern<IReadOnlyList<T>>>, IEquatable<ReadOnlyListPattern<T>>
Type Parameters
TThe type of values in the list.
- Inheritance
-
Pattern<IReadOnlyList<T>>ReadOnlyListPattern<T>
- Implements
- Inherited Members
Constructors
ReadOnlyListPattern(ReadOnlyListPattern<T>)
protected ReadOnlyListPattern(ReadOnlyListPattern<T> original)
Parameters
originalReadOnlyListPattern<T>
ReadOnlyListPattern(ImmutableArray<Pattern<T>>)
Defines the pattern matching on a sequence of elements.
public ReadOnlyListPattern(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 ReadOnlyListPattern<T> Empty { get; }
Property Value
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(Pattern<IReadOnlyList<T>>?)
public override sealed bool Equals(Pattern<IReadOnlyList<T>>? other)
Parameters
otherPattern<IReadOnlyList<T>>
Returns
Equals(ReadOnlyListPattern<T>?)
public virtual bool Equals(ReadOnlyListPattern<T>? other)
Parameters
otherReadOnlyListPattern<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(IReadOnlyList<T>, MatchingContext)
Attempts to match the provided input to the pattern.
public override IMatchNode<IReadOnlyList<T>>? Match(IReadOnlyList<T> input, MatchingContext context)
Parameters
inputIReadOnlyList<T>The input to match.
contextMatchingContextThe context in which to match the pattern to.
Returns
- IMatchNode<IReadOnlyList<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 ==(ReadOnlyListPattern<T>?, ReadOnlyListPattern<T>?)
public static bool operator ==(ReadOnlyListPattern<T>? left, ReadOnlyListPattern<T>? right)
Parameters
leftReadOnlyListPattern<T>rightReadOnlyListPattern<T>
Returns
operator !=(ReadOnlyListPattern<T>?, ReadOnlyListPattern<T>?)
public static bool operator !=(ReadOnlyListPattern<T>? left, ReadOnlyListPattern<T>? right)
Parameters
leftReadOnlyListPattern<T>rightReadOnlyListPattern<T>