本文整理汇总了C#中System.Activities.OutArgument<T>类的典型用法代码示例。如果您正苦于以下问题:C# OutArgument<T>类的具体用法?C# OutArgument<T>怎么用?C# OutArgument<T>使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OutArgument<T>类属于System.Activities命名空间,在下文中一共展示了OutArgument<T>类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
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")
},
},
}
};
示例2: Divide
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"]);
示例3: Execute
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);
}
}