OutArgument<T> Class

Definition

表示数据流出活动的绑定终端。A binding terminal that represents the flow of data out of an activity.

generic <typename T>
public ref class OutArgument sealed : System::Activities::OutArgument
[System.ComponentModel.TypeConverter(typeof(System.Activities.XamlIntegration.OutArgumentConverter))]
[System.Windows.Markup.ContentProperty("Expression")]
public sealed class OutArgument<T> : System.Activities.OutArgument
type OutArgument<'T> = class
    inherit OutArgument
Public NotInheritable Class OutArgument(Of T)
Inherits OutArgument

Type Parameters

T

OutArgument<T> 的数据类型。The data type of the OutArgument<T>.

Inheritance
OutArgument<T>
Attributes

Examples

下面的代码示例演示如何创建 OutArgument<T>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")
                    },
            },
        }
};

Remarks

OutArgument<T> 用于将数据流出活动。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. 在此示例中,使用一个具有两个输入自变量和一个输出自变量的自定义 Divide 活动作为工作流的根活动。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"]);

Divide 活动使用自变量接收输入值,并提供计算所得的结果值。The Divide activity uses arguments to receive the input values and to provide the computed result values. Remainder OutArgument<T> 用于传递除法的余数,而 Activity<TResult> 派生的活动提供的 Result 输出参数用于传递商。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.

Note

如果您的自定义活动是从采用 CodeActivity<TResult> 作为其泛型类型参数的泛型 Int32 派生的,则当您使用 WorkflowInvoker 调用方法调用该活动时,它将返回一个 Int32 值。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. 此外,CodeActivity<TResult>.Execute 方法将返回 Int32 值而不是 void,并且无需设置返回值。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);
    }
}

Constructors

OutArgument<T>()

使用默认值初始化 OutArgument<T> 类的新实例。Initialize a new instance of the OutArgument<T> class using default values.

OutArgument<T>(Activity<Location<T>>)

使用指定的 OutArgument<T> 初始化 Activity<TResult> 类的新实例。Initializes a new instance of the OutArgument<T> class using the specified Activity<TResult>.

OutArgument<T>(DelegateArgument)

使用指定的 OutArgument<T> 初始化 DelegateArgument 类的新实例。Initializes a new instance of the OutArgument<T> class using the specified DelegateArgument.

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

使用指定的表达式初始化 OutArgument<T> 类的新实例。Initializes a new instance of the OutArgument<T> class using the specified expression.

OutArgument<T>(Variable)

使用指定的 OutArgument<T> 初始化 Variable 类的新实例。Initializes a new instance of the OutArgument<T> class using the specified Variable.

Fields

ResultValue

表示“Result”的常量值,该值对应于表达式基类 Result 中类型为 OutArgumentActivityWithResult 属性的名称。Represents the constant value of "Result", which corresponds to the name of the Result property of type OutArgument in the expression base class ActivityWithResult.

(Inherited from Argument)

Properties

ArgumentType

获取数据绑定到此 Argument 的数据类型。Gets the data type for the data bound to this Argument.

(Inherited from Argument)
Direction

获取 ArgumentDirection,该值指定 Argument 是表示数据流入活动、流出活动还是流入和流出活动。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)
EvaluationOrder

获取或设置一个从零开始的值,该值指定自变量的计算顺序。Gets or sets a zero-based value that specifies the order in which the argument is evaluated.

(Inherited from Argument)
Expression

获取一个表示此 Activity<TResult> 的值的 OutArgument<T>Gets an Activity<TResult> that represents the value of this OutArgument<T>.

Methods

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
FromDelegateArgument(DelegateArgument)

初始化和返回使用指定的 OutArgument<T> 构造的新 DelegateArgumentInitializes and returns a new OutArgument<T> constructed using the specified DelegateArgument.

FromExpression(Activity<Location<T>>)

初始化和返回使用指定的 OutArgument<T> 构造的新 Activity<TResult>Initializes and returns a new OutArgument<T> constructed using the specified Activity<TResult>.

FromVariable(Variable)

初始化和返回使用指定的 OutArgument<T> 构造的新 VariableInitializes and returns a new OutArgument<T> constructed using the specified Variable.

Get(ActivityContext)

使用指定的活动上下文获取 OutArgument<T> 的值。Gets the value of the OutArgument<T> using the specified activity context.

Get<T>(ActivityContext)

使用指定类型和活动上下文获取自变量的值。Gets the value of the argument using the specified type and activity context.

(Inherited from Argument)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetLocation(ActivityContext)

获取 OutArgument<T> 的值的位置。Gets the location of the value for the OutArgument<T>.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Set(ActivityContext, Object)

使用指定活动上下文设置参数的值。Sets the value of the argument using the specified activity context.

(Inherited from Argument)
Set(ActivityContext, T)

使用指定活动上下文设置 OutArgument<T> 的值。Sets the value of the OutArgument<T> using the specified activity context.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

Operators

Implicit(Activity<Location<T>> to OutArgument<T>)

初始化和返回使用指定的 OutArgument<T> 构造的新 Activity<TResult>Initializes and returns a new OutArgument<T> constructed using the specified Activity<TResult>.

Implicit(DelegateArgument to OutArgument<T>)

初始化和返回使用指定的 OutArgument<T> 构造的新 DelegateArgumentInitializes and returns a new OutArgument<T> constructed using the specified DelegateArgument.

Implicit(Variable to OutArgument<T>)

初始化和返回使用指定的 OutArgument<T> 构造的新 VariableInitializes and returns a new OutArgument<T> constructed using the specified Variable.

Applies to