Class OrPattern<T>
Defines the pattern that combines multiple sub-patterns for which at least one needs to be satisfied.
public sealed record OrPattern<T> : Pattern<T>, IEquatable<Pattern>, IEquatable<Pattern<T>>, IEquatable<OrPattern<T>>
Type Parameters
TThe type of value to match.
- Inheritance
-
Pattern<T>OrPattern<T>
- Implements
-
IEquatable<Pattern<T>>IEquatable<OrPattern<T>>
- Inherited Members
Constructors
OrPattern(ImmutableArray<Pattern<T>>)
Defines the pattern that combines multiple sub-patterns for which at least one needs to be satisfied.
public OrPattern(ImmutableArray<Pattern<T>> Operands)
Parameters
OperandsImmutableArray<Pattern<T>>The sub patterns.
Properties
EqualityContract
protected override Type EqualityContract { get; }
Property Value
Operands
The sub patterns.
public ImmutableArray<Pattern<T>> Operands { get; init; }
Property Value
Methods
Deconstruct(out ImmutableArray<Pattern<T>>)
public void Deconstruct(out ImmutableArray<Pattern<T>> Operands)
Parameters
OperandsImmutableArray<Pattern<T>>
Equals(OrPattern<T>?)
public bool Equals(OrPattern<T>? other)
Parameters
otherOrPattern<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 ==(OrPattern<T>?, OrPattern<T>?)
public static bool operator ==(OrPattern<T>? left, OrPattern<T>? right)
Parameters
Returns
operator !=(OrPattern<T>?, OrPattern<T>?)
public static bool operator !=(OrPattern<T>? left, OrPattern<T>? right)