Switch<T> Constructor

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

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Switch<T>() Creates a new instance of the Switch<T> class.
Public method Switch<T>(Activity<T>) Creates a new instance of the Switch<T> class with the specified expression.
Public method Switch<T>(Expression<Func<ActivityContext, T>>) Creates a new instance of the Switch<T> class with the specified expression.
Public method Switch<T>(InArgument<T>) Creates a new instance of the Switch<T> class with the specified expression.
Top

The following code sample demonstrates creating a Switch<T> activity. This example is from the Using Procedural Activities sample.

// 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" } }
    }
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft