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 ();

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Switch<T>(Activity<T>)

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

public Switch (System.Activities.Activity<T> expression);

Parameters

expression
Activity<T>

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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

Switch<T>(InArgument<T>)

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

public Switch (System.Activities.InArgument<T> expression);

Parameters

expression
InArgument<T>

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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

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);

Parameters

expression
Expression<Func<ActivityContext,T>>

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

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1