簡體   English   中英

C#工作流程變量

[英]c# workflow variable

我正在使用Windows Workflow Foundation處理ac#項目。 我正在編寫一些自定義活動,而我沒有使用設計器。 我有以下代碼,我將在一段時間內將其分配給局部變量。 我如何在while活動中訪問StepNo的值? 有什么幫助嗎?

While wfWhile = new While();

//temporary Assign activity, remove it later
Variable<int> stepNo = new Variable<int>("stepNo", 0);  

wfWhile.Variables.Add(stepNo);

多數情況下,執行此操作的方法不同,但VisualBasicValue<T>是執行此操作的方法。 以下代碼循環執行,直到stepNo變為10,然后打印stepNo的值並將其遞增。

While wfWhile = new While();
Variable<int> stepNo = new Variable<int>("stepNo", 0);
wfWhile.Variables.Add(stepNo);

wfWhile.Body = new Sequence()
{
    Activities = {
        new WriteLine
        {
            Text = new VisualBasicValue<string>("\"Step: \" & stepNo ")
        },
        new Assign<int>()
        {
                To = new OutArgument<int>(stepNo),
                Value= new VisualBasicValue<int>("stepNo + 1")
        }

        }
};
wfWhile.Condition = new VisualBasicValue<bool>("stepNo < 10");
WorkflowInvoker.Invoke(wfWhile);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM