Table of Contents

Class LiteralPattern<T>

Namespace
CilFi.Patterns
Assembly
CilFi.Core.dll

Defines the pattern matching on exact instances of a type.

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

Type Parameters

T

The type of values to match.

Inheritance
LiteralPattern<T>
Implements
Inherited Members

Constructors

LiteralPattern(LiteralPattern<T>)

protected LiteralPattern(LiteralPattern<T> original)

Parameters

original LiteralPattern<T>

LiteralPattern(T)

Defines the pattern matching on exact instances of a type.

public LiteralPattern(T Value)

Parameters

Value T

The expected instance of the type.

Properties

EqualityContract

protected override Type EqualityContract { get; }

Property Value

Type

Value

The expected instance of the type.

public T Value { get; init; }

Property Value

T

Methods

Deconstruct(out T)

public void Deconstruct(out T Value)

Parameters

Value T

Equals(LiteralPattern<T>?)

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

Parameters

other LiteralPattern<T>

Returns

bool

Equals(Pattern<T>?)

public override sealed 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 override void Format(IndentedTextWriter writer)

Parameters

writer IndentedTextWriter

The output stream.

GetHashCode()

public override int GetHashCode()

Returns

int

Match(T, MatchingContext)

Attempts to match the provided input to the pattern.

public override 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

Operators

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

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

Parameters

left LiteralPattern<T>
right LiteralPattern<T>

Returns

bool

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

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

Parameters

left LiteralPattern<T>
right LiteralPattern<T>

Returns

bool