Show / Hide Table of Contents

Class SwitchBuilder

Represents selection statement that chooses a single section to execute from a list of candidates based on a pattern matching.

Inheritance
object
ExpressionBuilder<SwitchExpression>
SwitchBuilder
Implements
ISupplier<SwitchExpression>
IFunctional<Func<SwitchExpression>>
Inherited Members
ExpressionBuilder<SwitchExpression>.OfType(Type)
ExpressionBuilder<SwitchExpression>.OfType<T>()
ExpressionBuilder<SwitchExpression>.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 SwitchBuilder : ExpressionBuilder<SwitchExpression>, ISupplier<SwitchExpression>, IFunctional<Func<SwitchExpression>>

Methods

| Edit this page View Source

Case(IEnumerable<Expression>, Action)

Specifies a pattern to compare to the match expression and action to be executed if matching is successful.

Declaration
public SwitchBuilder Case(IEnumerable<Expression> testValues, Action body)
Parameters
Type Name Description
IEnumerable<Expression> testValues

A list of test values.

Action body

The block code to be executed if input value is equal to one of test values.

Returns
Type Description
SwitchBuilder

Modified selection builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Edit this page View Source

Case(IEnumerable<Expression>, Expression)

Specifies a pattern to compare to the match expression and expression to be returned if matching is successful.

Declaration
public SwitchBuilder Case(IEnumerable<Expression> testValues, Expression body)
Parameters
Type Name Description
IEnumerable<Expression> testValues

A list of test values.

Expression body

The expression to be returned from selection statement.

Returns
Type Description
SwitchBuilder

this builder.

| Edit this page View Source

Case(Expression, Action)

Specifies a pattern to compare to the match expression and action to be executed if matching is successful.

Declaration
public SwitchBuilder Case(Expression test, Action body)
Parameters
Type Name Description
Expression test

Single test value.

Action body

The block code to be executed if input value is equal to one of test values.

Returns
Type Description
SwitchBuilder

Modified selection builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Edit this page View Source

Case(Expression, Expression)

Specifies a pattern to compare to the match expression and expression to be returned if matching is successful.

Declaration
public SwitchBuilder Case(Expression test, Expression body)
Parameters
Type Name Description
Expression test

Single test value.

Expression body

The expression to be returned from selection statement.

Returns
Type Description
SwitchBuilder

this builder.

| Edit this page View Source

Default(Action)

Specifies the switch section to execute if the match expression doesn't match any other cases.

Declaration
public SwitchBuilder Default(Action body)
Parameters
Type Name Description
Action body

The block code to be executed if input value is equal to one of test values.

Returns
Type Description
SwitchBuilder

Modified selection builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Edit this page View Source

Default(Expression)

Specifies the switch section to execute if the match expression doesn't match any other cases.

Declaration
public SwitchBuilder Default(Expression body)
Parameters
Type Name Description
Expression body

The expression to be returned from selection statement in default case.

Returns
Type Description
SwitchBuilder

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)

See Also

switch statement
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾