《WF in 24 Hours》读书笔记 - Hour 2(2) - Workflow:创建分支和传递参数

1. 修改workflow1.xaml,添加Flowchart,添加Flowdesicion,添加CodeActivity2,并且名字改为下图所示:

2. CodeActivity1和2的代码如下:

 1     public sealed class CodeActivity1 : CodeActivity
 2     {
 3         // Define an activity input argument of type string
 4         public InArgument<string> Text { get; set; }
 5 
 6         // If your activity returns a value, derive from CodeActivity<TResult>
 7         // and return the value from the Execute method.
 8         protected override void Execute(CodeActivityContext context)
 9         {
10             Console.WriteLine("executed in the left branch");
11         }
12 }
13 
14     public sealed class CodeActivity2 : CodeActivity
15     {
16         // Define an activity input argument of type string
17         public InArgument<string> Text { get; set; }
18 
19         // If your activity returns a value, derive from CodeActivity<TResult>
20         // and return the value from the Execute method.
21         protected override void Execute(CodeActivityContext context)
22         {
23             Console.WriteLine("executed in the right branch");
24         }
25     }

3. 修改program.cs

 1         static void Main(string[] args)
 2         {
 3             // Add the parameters via a dictionary object
 4             Dictionary<string, object> parameters = new Dictionary<string, object>();
 5             parameters.Add("Amount", 1200);
 6 
 7             Activity workflow1 = new Workflow1();
 8             WorkflowInvoker.Invoke(workflow1, parameters);
 9 
10             // Pause the display
11             Console.WriteLine("Press enter to continue.");
12             Console.Read();
13         }

4. 打开Workflow1.xaml文件,设置Flowdecision的condition为Amount < 1000

5. 还是在workflow1.xaml中添加Argument

6. 运行。结果如下:

7. 修改program.cs的Amount为900,运行。结果如下:

转载于:https://www.cnblogs.com/ilovewindy/p/3709334.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值