Switch<T> Constructors

Definition

Creates a new instance of the Switch<T> class.

Overloads

Switch<T>()

Creates a new instance of the Switch<T> class.

Switch<T>(Activity<T>)

Creates a new instance of the Switch<T> class with the specified expression.

Switch<T>(InArgument<T>)

Creates a new instance of the Switch<T> class with the specified expression.

Switch<T>(Expression<Func<ActivityContext,T>>)

Creates a new instance of the Switch<T> class with the specified expression.

Examples

The following code sample demonstrates creating a Switch<T> activity.

// check if the number is ok...
new Switch<int>()
{
    DisplayName = "Verify Value from User",
    Expression = ExpressionServices.Convert<int>( env => numberFromUser.Get(env).CompareTo(numberToGuess.Get(env)) ),
    Cases =
    {
        { 0, new Assign<bool>()
            {
                To = new OutArgument<bool>(finished),
                Value = true
            }
        },
        {  1, new WriteLine() { Text = "    Try a lower number number..." } },
        { -1, new WriteLine() { Text = "    Try a higher number" } }
    }
}

Switch<T>()

Creates a new instance of the Switch<T> class.

public:
 Switch();
public Switch ();
Public Sub New ()

Examples

The following code sample demonstrates creating a Switch<T> activity.

// check if the number is ok...
new Switch<int>()
{
    DisplayName = "Verify Value from User",
    Expression = ExpressionServices.Convert<int>( env => numberFromUser.Get(env).CompareTo(numberToGuess.Get(env)) ),
    Cases =
    {
        { 0, new Assign<bool>()
            {
                To = new OutArgument<bool>(finished),
                Value = true
            }
        },
        {  1, new WriteLine() { Text = "    Try a lower number number..." } },
        { -1, new WriteLine() { Text = "    Try a higher number" } }
    }
}

Applies to

Switch<T>(Activity<T>)

Creates a new instance of the Switch<T> class with the specified expression.

public:
 Switch(System::Activities::Activity<T> ^ expression);
public Switch (System.Activities.Activity<T> expression);
new System.Activities.Statements.Switch<'T> : System.Activities.Activity<'T> -> System.Activities.Statements.Switch<'T>
Public Sub New (expression As Activity(Of T))

Parameters

expression
Activity<T>

The expression to evaluate and compare against the values in the Cases dictionary.

Applies to

Switch<T>(InArgument<T>)

Creates a new instance of the Switch<T> class with the specified expression.

public:
 Switch(System::Activities::InArgument<T> ^ expression);
public Switch (System.Activities.InArgument<T> expression);
new System.Activities.Statements.Switch<'T> : System.Activities.InArgument<'T> -> System.Activities.Statements.Switch<'T>
Public Sub New (expression As InArgument(Of T))

Parameters

expression
InArgument<T>

The expression to evaluate and compare against the values in the Cases dictionary.

Applies to

Switch<T>(Expression<Func<ActivityContext,T>>)

Creates a new instance of the Switch<T> class with the specified expression.

public:
 Switch(System::Linq::Expressions::Expression<Func<System::Activities::ActivityContext ^, T> ^> ^ expression);
public Switch (System.Linq.Expressions.Expression<Func<System.Activities.ActivityContext,T>> expression);
new System.Activities.Statements.Switch<'T> : System.Linq.Expressions.Expression<Func<System.Activities.ActivityContext, 'T>> -> System.Activities.Statements.Switch<'T>
Public Sub New (expression As Expression(Of Func(Of ActivityContext, T)))

Parameters

expression
Expression<Func<ActivityContext,T>>

The expression to evaluate and compare against the values in the Cases dictionary.

Applies to