OutArgument<T> Class

.NET Framework (current version)
 

A binding terminal that represents the flow of data out of an activity.

Namespace:   System.Activities
Assembly:  System.Activities (in System.Activities.dll)

System.Object
  System.Activities.Argument
    System.Activities.OutArgument
      System.Activities.OutArgument<T>

[ContentPropertyAttribute("Expression")]
[TypeConverterAttribute(typeof(OutArgumentConverter))]
public sealed class OutArgument<T> : OutArgument

Type Parameters

T

The data type of the OutArgument<T>.

NameDescription
System_CAPS_pubmethodOutArgument<T>()

Initialize a new instance of the OutArgument<T> class using default values.

System_CAPS_pubmethodOutArgument<T>(Activity<Location<T>>)

Initializes a new instance of the OutArgument<T> class using the specified Activity<TResult>.

System_CAPS_pubmethodOutArgument<T>(DelegateArgument)

Initializes a new instance of the OutArgument<T> class using the specified DelegateArgument.

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

Initializes a new instance of the OutArgument<T> class using the specified expression.

System_CAPS_pubmethodOutArgument<T>(Variable)

Initializes a new instance of the OutArgument<T> class using the specified Variable.

NameDescription
System_CAPS_pubpropertyArgumentType

Gets the data type for the data bound to this Argument.(Inherited from Argument.)

System_CAPS_pubpropertyDirection

Gets an ArgumentDirection that specifies whether the Argument represents the flow of data into an activity, out of an activity, or both into and out of an activity. (Inherited from Argument.)

System_CAPS_pubpropertyEvaluationOrder

Gets or sets a zero-based value that specifies the order in which the argument is evaluated.(Inherited from Argument.)

System_CAPS_pubpropertyExpression

Gets an Activity<TResult> that represents the value of this OutArgument<T>.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticFromDelegateArgument(DelegateArgument)

Initializes and returns a new OutArgument<T> constructed using the specified DelegateArgument.

System_CAPS_pubmethodSystem_CAPS_staticFromExpression(Activity<Location<T>>)

Initializes and returns a new OutArgument<T> constructed using the specified Activity<TResult>.

System_CAPS_pubmethodSystem_CAPS_staticFromVariable(Variable)

Initializes and returns a new OutArgument<T> constructed using the specified Variable.

System_CAPS_pubmethodGet(ActivityContext)

Gets the value of the OutArgument<T> using the specified activity context.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLocation(ActivityContext)

Gets the location of the value for the OutArgument<T>.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSet(ActivityContext, T)

Sets the value of the OutArgument<T> using the specified activity context.

System_CAPS_pubmethodSet(ActivityContext, Object)

Sets the value of the argument using the specified activity context.(Inherited from Argument.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticImplicit(Activity<Location<T>> to OutArgument<T>)

Initializes and returns a new OutArgument<T> constructed using the specified Activity<TResult>.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(DelegateArgument to OutArgument<T>)

Initializes and returns a new OutArgument<T> constructed using the specified DelegateArgument.

System_CAPS_puboperatorSystem_CAPS_staticImplicit(Variable to OutArgument<T>)

Initializes and returns a new OutArgument<T> constructed using the specified Variable.

An OutArgument<T> is used to flow data out of an activity. If the activity is the root activity of a workflow, then it is also used to flow data out of the workflow to the workflow host. In this example, a custom Divide activity that has two input arguments and one output argument is used as the root activity of a workflow. The host application passes two values into the workflow and then retrieves the result of the division after the workflow completes.

int dividend = 500;
int divisor = 36;

Dictionary<string, object> arguments = new Dictionary<string, object>();
arguments.Add("Dividend", dividend);
arguments.Add("Divisor", divisor);

IDictionary<string, object> outputs =
    WorkflowInvoker.Invoke(new Divide(), arguments);

Console.WriteLine("{0} / {1} = {2} Remainder {3}",
    dividend, divisor, outputs["Result"], outputs["Remainder"]);

The Divide activity uses arguments to receive the input values and to provide the computed result values. The Remainder OutArgument<T> is used to pass out the remainder of the division, and the Result output argument provided by Activity<TResult> derived activities is used to pass out the quotient.

System_CAPS_noteNote

If your custom activity is derived from the generic CodeActivity<TResult> with an Int32 as its generic type argument, when you invoke the activity with the WorkflowInvoker Invoke method, it returns an Int32 value. In Addition, the CodeActivity<TResult>.Execute method will return an Int32 value instead of void and you do not need to set a return value.

public sealed class Divide : CodeActivity
{
    [RequiredArgument]
    public InArgument<int> Dividend { get; set; }

    [RequiredArgument]
    public InArgument<int> Divisor { get; set; }

    public OutArgument<int> Remainder { get; set; }
    public OutArgument<int> Result { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        int quotient = Dividend.Get(context) / Divisor.Get(context);
        int remainder = Dividend.Get(context) % Divisor.Get(context);

        Result.Set(context, quotient);
        Remainder.Set(context, remainder);
    }
}

The following code sample demonstrates creating an OutArgument<T>. This example is from the Formatter sample.

Sequence workflow = new Sequence
{
    Variables = { mealExpense, result },
    Activities =
        {
            new Assign<Expense>
            {
               Value = new InArgument<Expense>( (e) => new Meal { Amount = 50, Location = "Redmond", Vendor = "KFC" }),
               To = new OutArgument<Expense>(mealExpense)
            },
            new WriteLine 
            {
                Text = new InArgument<string>("Hello")
            },
            approveExpense,
            new ReceiveReply
            {
                Request = approveExpense,                            
                Content = ReceiveContent.Create(new OutArgument<bool>(result))
            },

            new If
            {
               Condition = new InArgument<bool> (result),
               Then =                         
                    new WriteLine
                    {
                        Text = new InArgument<string>("Expense Approved")
                    },
               Else =                         
                    new WriteLine
                    {
                        Text = new InArgument<string>("Expense Cannot be Approved")
                    },
            },

        }
};

.NET Framework
Available since 4.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: