Class AnyPattern<T>
Defines the pattern that accepts any instance of the provided type.
public sealed record AnyPattern<T> : Pattern<T?>, IEquatable<Pattern>, IEquatable<Pattern<T?>>, IEquatable<AnyPattern<T>>
Type Parameters
TThe type of values to match.
- Inheritance
-
Pattern<T>AnyPattern<T>
- Implements
-
IEquatable<Pattern<T>>IEquatable<AnyPattern<T>>
- Inherited Members
Constructors
AnyPattern()
public AnyPattern()
Properties
EqualityContract
protected override Type EqualityContract { get; }
Property Value
Instance
Gets the singleton instance of the pattern.
public static AnyPattern<T> Instance { get; }
Property Value
- AnyPattern<T>
IsAny
Gets a value indicating this pattern matches any object of the intended type.
public override bool IsAny { get; }
Property Value
Methods
Equals(AnyPattern<T>?)
public bool Equals(AnyPattern<T>? other)
Parameters
otherAnyPattern<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 ==(AnyPattern<T>?, AnyPattern<T>?)
public static bool operator ==(AnyPattern<T>? left, AnyPattern<T>? right)
Parameters
leftAnyPattern<T>rightAnyPattern<T>
Returns
operator !=(AnyPattern<T>?, AnyPattern<T>?)
public static bool operator !=(AnyPattern<T>? left, AnyPattern<T>? right)
Parameters
leftAnyPattern<T>rightAnyPattern<T>