當前位置: 首頁>>代碼示例>>C#>>正文


C# OutArgument<T>類代碼示例

本文整理匯總了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")
                    },
            },
        }
};
開發者ID:.NET開發者,項目名稱:System.Activities,代碼行數:37,代碼來源:OutArgument

示例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"]);
開發者ID:.NET開發者,項目名稱:System.Activities,代碼行數:12,代碼來源:OutArgument

示例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);
    }
}
開發者ID:.NET開發者,項目名稱:System.Activities,代碼行數:20,代碼來源:OutArgument


注:本文中的System.Activities.OutArgument<T>類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。