Show / Hide Table of Contents

Class MatchBuilder

Represents pattern matcher.

Inheritance
object
ExpressionBuilder<BlockExpression>
MatchBuilder
Implements
ISupplier<BlockExpression>
IFunctional<Func<BlockExpression>>
Inherited Members
ExpressionBuilder<BlockExpression>.OfType(Type)
ExpressionBuilder<BlockExpression>.OfType<T>()
ExpressionBuilder<BlockExpression>.End()
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Metaprogramming
Assembly: DotNext.Metaprogramming.dll
Syntax
public sealed class MatchBuilder : ExpressionBuilder<BlockExpression>, ISupplier<BlockExpression>, IFunctional<Func<BlockExpression>>

Methods

| Edit this page View Source

Case(Pattern, CaseStatement)

Defines pattern matching.

Declaration
public MatchBuilder Case(MatchBuilder.Pattern pattern, MatchBuilder.CaseStatement body)
Parameters
Type Name Description
MatchBuilder.Pattern pattern

The condition representing pattern.

MatchBuilder.CaseStatement body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(Pattern, Action<ParameterExpression>)

Defines pattern matching.

Declaration
public MatchBuilder Case(MatchBuilder.Pattern pattern, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder.Pattern pattern

The condition representing pattern.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(Pattern, Expression)

Defines pattern matching.

Declaration
public MatchBuilder Case(MatchBuilder.Pattern pattern, Expression value)
Parameters
Type Name Description
MatchBuilder.Pattern pattern

The condition representing pattern.

Expression value

The value to be supplied if the specified pattern matches to the passed object.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(object, CaseStatement)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(object structPattern, MatchBuilder.CaseStatement body)
Parameters
Type Name Description
object structPattern

The structure pattern represented by instance of anonymous type.

MatchBuilder.CaseStatement body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(object, Action<ParameterExpression>)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(object structPattern, Action<ParameterExpression> body)
Parameters
Type Name Description
object structPattern

The structure pattern represented by instance of anonymous type.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(object, Expression)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(object structPattern, Expression value)
Parameters
Type Name Description
object structPattern

The structure pattern represented by instance of anonymous type.

Expression value

The value to be supplied if the specified structural pattern matches to the passed object.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(string, Expression, Action<MemberExpression>)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(string memberName, Expression memberValue, Action<MemberExpression> body)
Parameters
Type Name Description
string memberName

The name of the field or property.

Expression memberValue

The expected value of the field or property.

Action<MemberExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(string, Expression, Func<MemberExpression, Expression>)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(string memberName, Expression memberValue, Func<MemberExpression, Expression> body)
Parameters
Type Name Description
string memberName

The name of the field or property.

Expression memberValue

The expected value of the field or property.

Func<MemberExpression, Expression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(string, Expression, string, Expression, Action<MemberExpression, MemberExpression>)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(string memberName1, Expression memberValue1, string memberName2, Expression memberValue2, Action<MemberExpression, MemberExpression> body)
Parameters
Type Name Description
string memberName1

The name of the first field or property.

Expression memberValue1

The expected value of the first field or property.

string memberName2

The name of the second field or property.

Expression memberValue2

The expected value of the second field or property.

Action<MemberExpression, MemberExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(string, Expression, string, Expression, Func<MemberExpression, MemberExpression, Expression>)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(string memberName1, Expression memberValue1, string memberName2, Expression memberValue2, Func<MemberExpression, MemberExpression, Expression> body)
Parameters
Type Name Description
string memberName1

The name of the first field or property.

Expression memberValue1

The expected value of the first field or property.

string memberName2

The name of the second field or property.

Expression memberValue2

The expected value of the second field or property.

Func<MemberExpression, MemberExpression, Expression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(string, Expression, string, Expression, string, Expression, Action<MemberExpression, MemberExpression, MemberExpression>)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(string memberName1, Expression memberValue1, string memberName2, Expression memberValue2, string memberName3, Expression memberValue3, Action<MemberExpression, MemberExpression, MemberExpression> body)
Parameters
Type Name Description
string memberName1

The name of the first field or property.

Expression memberValue1

The expected value of the first field or property.

string memberName2

The name of the second field or property.

Expression memberValue2

The expected value of the second field or property.

string memberName3

The name of the third field or property.

Expression memberValue3

The expected value of the third field or property.

Action<MemberExpression, MemberExpression, MemberExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(string, Expression, string, Expression, string, Expression, Func<MemberExpression, MemberExpression, MemberExpression, Expression>)

Defines pattern matching based on structural matching.

Declaration
public MatchBuilder Case(string memberName1, Expression memberValue1, string memberName2, Expression memberValue2, string memberName3, Expression memberValue3, Func<MemberExpression, MemberExpression, MemberExpression, Expression> body)
Parameters
Type Name Description
string memberName1

The name of the first field or property.

Expression memberValue1

The expected value of the first field or property.

string memberName2

The name of the second field or property.

Expression memberValue2

The expected value of the second field or property.

string memberName3

The name of the third field or property.

Expression memberValue3

The expected value of the third field or property.

Func<MemberExpression, MemberExpression, MemberExpression, Expression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(Type, CaseStatement)

Defines pattern matching based on the expected type of value.

Declaration
public MatchBuilder Case(Type expectedType, MatchBuilder.CaseStatement body)
Parameters
Type Name Description
Type expectedType

The expected type of the value.

MatchBuilder.CaseStatement body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

Remarks

This method equivalent to case T value: body();.

| Edit this page View Source

Case(Type, Pattern, CaseStatement)

Defines pattern matching based on the expected type of value.

Declaration
public MatchBuilder Case(Type expectedType, MatchBuilder.Pattern pattern, MatchBuilder.CaseStatement body)
Parameters
Type Name Description
Type expectedType

The expected type of the value.

MatchBuilder.Pattern pattern

Additional condition associated with the value.

MatchBuilder.CaseStatement body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

Remarks

This method equivalent to case T value where condition(value): body();.

| Edit this page View Source

Case(Type, Pattern, Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public MatchBuilder Case(Type expectedType, MatchBuilder.Pattern pattern, Action<ParameterExpression> body)
Parameters
Type Name Description
Type expectedType

The expected type of the value.

MatchBuilder.Pattern pattern

Additional condition associated with the value.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case(Type, Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public MatchBuilder Case(Type expectedType, Action<ParameterExpression> body)
Parameters
Type Name Description
Type expectedType

The expected type of the value.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Case<T>(CaseStatement)

Defines pattern matching based on the expected type of value.

Declaration
public MatchBuilder Case<T>(MatchBuilder.CaseStatement body)
Parameters
Type Name Description
MatchBuilder.CaseStatement body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

Type Parameters
Name Description
T

The expected type of the value.

| Edit this page View Source

Case<T>(Pattern, Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public MatchBuilder Case<T>(MatchBuilder.Pattern pattern, Action<ParameterExpression> body)
Parameters
Type Name Description
MatchBuilder.Pattern pattern

Additional condition associated with the value.

Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

Type Parameters
Name Description
T

The expected type of the value.

| Edit this page View Source

Case<T>(Action<ParameterExpression>)

Defines pattern matching based on the expected type of value.

Declaration
public MatchBuilder Case<T>(Action<ParameterExpression> body)
Parameters
Type Name Description
Action<ParameterExpression> body

The action to be executed if object matches to the pattern.

Returns
Type Description
MatchBuilder

this builder.

Type Parameters
Name Description
T

The expected type of the value.

| Edit this page View Source

Default(CaseStatement)

Defines default behavior in case when all defined patterns are false positive.

Declaration
public MatchBuilder Default(MatchBuilder.CaseStatement body)
Parameters
Type Name Description
MatchBuilder.CaseStatement body

The block of code to be evaluated as default case.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Default(Action<ParameterExpression>)

Defines default behavior in case when all defined patterns are false positive.

Declaration
public MatchBuilder Default(Action<ParameterExpression> body)
Parameters
Type Name Description
Action<ParameterExpression> body

The body to be executed as default case.

Returns
Type Description
MatchBuilder

this builder.

| Edit this page View Source

Default(Expression)

Defines default behavior in case when all defined patterns are false positive.

Declaration
public MatchBuilder Default(Expression value)
Parameters
Type Name Description
Expression value

The expression to be evaluated as default case.

Returns
Type Description
MatchBuilder

this builder.

Implements

ISupplier<TResult>
IFunctional<TDelegate>

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾