Class MatchBuilder
Represents pattern matcher.
Inherited Members
Namespace: DotNext.Metaprogramming
Assembly: DotNext.Metaprogramming.dll
Syntax
public sealed class MatchBuilder : ExpressionBuilder<BlockExpression>, ISupplier<BlockExpression>, IFunctional<Func<BlockExpression>>
  Methods
| Edit this page View SourceCase(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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
Remarks
This method equivalent to case T value: body();.
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 | 
  | 
      
Remarks
This method equivalent to case T value where condition(value): body();.
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 | 
  | 
      
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 | 
  | 
      
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 | 
  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The expected type of the value.  | 
      
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 | 
  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The expected type of the value.  | 
      
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 | 
  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The expected type of the value.  | 
      
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 | 
  | 
      
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 | 
  | 
      
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 | 
  |