Table of Contents

Class Pattern<T>

Namespace
CilFi.Patterns
Assembly
CilFi.Core.dll

Defines a pattern for a specific type of value.

public abstract record Pattern<T> : Pattern, IEquatable<Pattern>, IEquatable<Pattern<T>>

Type Parameters

T

The type ofthe value to match on

Inheritance
Pattern<T>
Implements
Derived
Inherited Members

Constructors

Pattern()

protected Pattern()

Pattern(Pattern<T>)

protected Pattern(Pattern<T> original)

Parameters

original Pattern<T>

Properties

EqualityContract

protected override Type EqualityContract { get; }

Property Value

Type

Methods

AsObject()

Wraps the pattern into a more generalized Pattern<T>.

public override Pattern<object?> AsObject()

Returns

Pattern<object>

The pattern.

Equals(Pattern?)

public override sealed bool Equals(Pattern? other)

Parameters

other Pattern

Returns

bool

Equals(Pattern<T>?)

public virtual bool Equals(Pattern<T>? other)

Parameters

other Pattern<T>

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Format(IndentedTextWriter)

Serializes the pattern to a readable string.

public abstract void Format(IndentedTextWriter writer)

Parameters

writer IndentedTextWriter

The output stream.

GetHashCode()

public override int GetHashCode()

Returns

int

IsMatch(T, MatchingContext)

Gets a value indicating the provided input matches the pattern.

public bool IsMatch(T input, MatchingContext context)

Parameters

input T

The input to match.

context MatchingContext

The context in which to match the pattern to.

Returns

bool

true if the input matches the pattern, false otherwise.

Match(T, MatchingContext)

Attempts to match the provided input to the pattern.

public abstract IMatchNode<T>? Match(T input, MatchingContext context)

Parameters

input T

The input to match.

context MatchingContext

The 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

builder StringBuilder

Returns

bool

ToString()

public override sealed string ToString()

Returns

string

Operators

operator &(Pattern<T>, Pattern<T>)

Combines two patterns into a pattern where both patterns should be satisfied.

public static Pattern<T> operator &(Pattern<T> a, Pattern<T> b)

Parameters

a Pattern<T>

The first pattern.

b Pattern<T>

The second pattern.

Returns

Pattern<T>

The resulting pattern.

operator |(Pattern<T>, Pattern<T>)

Combines two patterns into a pattern where at least one should be satisfied.

public static Pattern<T> operator |(Pattern<T> a, Pattern<T> b)

Parameters

a Pattern<T>

The first pattern.

b Pattern<T>

The second pattern.

Returns

Pattern<T>

The resulting pattern.

operator ==(Pattern<T>?, Pattern<T>?)

public static bool operator ==(Pattern<T>? left, Pattern<T>? right)

Parameters

left Pattern<T>
right Pattern<T>

Returns

bool

operator !=(Pattern<T>?, Pattern<T>?)

public static bool operator !=(Pattern<T>? left, Pattern<T>? right)

Parameters

left Pattern<T>
right Pattern<T>

Returns

bool