Class SetPattern<T>
Defines the pattern that matches on (sub)-sets of elements.
public record SetPattern<T> : Pattern<IList<T>>, IEquatable<Pattern>, IEquatable<Pattern<IList<T>>>, IEquatable<SetPattern<T>> where T : notnull
Type Parameters
T
- Inheritance
-
SetPattern<T>
- Implements
-
IEquatable<SetPattern<T>>
- Inherited Members
Constructors
SetPattern(SetPatternAttributes, ImmutableArray<Pattern<T>>)
Defines the pattern that matches on (sub)-sets of elements.
public SetPattern(SetPatternAttributes Attributes, ImmutableArray<Pattern<T>> Elements)
Parameters
AttributesSetPatternAttributesThe set matching rules.
ElementsImmutableArray<Pattern<T>>The elements that should appear in the set.
SetPattern(SetPattern<T>)
protected SetPattern(SetPattern<T> original)
Parameters
originalSetPattern<T>
Properties
Attributes
The set matching rules.
public SetPatternAttributes Attributes { get; init; }
Property Value
Elements
The elements that should appear in the set.
public ImmutableArray<Pattern<T>> Elements { get; init; }
Property Value
EqualityContract
protected override Type EqualityContract { get; }
Property Value
FixedOrder
Gets a value indicating the elements should be matched in a specific order.
public bool FixedOrder { get; }
Property Value
FullSet
Gets a value indicating the full set should be matched.
public bool FullSet { get; }
Property Value
Methods
Deconstruct(out SetPatternAttributes, out ImmutableArray<Pattern<T>>)
public void Deconstruct(out SetPatternAttributes Attributes, out ImmutableArray<Pattern<T>> Elements)
Parameters
AttributesSetPatternAttributesElementsImmutableArray<Pattern<T>>
Equals(Pattern<IList<T>>?)
public override sealed bool Equals(Pattern<IList<T>>? other)
Parameters
Returns
Equals(SetPattern<T>?)
public virtual bool Equals(SetPattern<T>? other)
Parameters
otherSetPattern<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(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 ==(SetPattern<T>?, SetPattern<T>?)
public static bool operator ==(SetPattern<T>? left, SetPattern<T>? right)
Parameters
leftSetPattern<T>rightSetPattern<T>
Returns
operator !=(SetPattern<T>?, SetPattern<T>?)
public static bool operator !=(SetPattern<T>? left, SetPattern<T>? right)
Parameters
leftSetPattern<T>rightSetPattern<T>