zoukankan      html  css  js  c++  java
  • 数据的传递 变量与参数的使用

    数据的传递 变量与参数的使用

    [参数] 可以用 [表达式方式] 与 [变量]绑定

    [In 参数],关联变量值可传入内部;内部修改参数时,关联变量不会更改

    说明:

    1.定义一个[InChangeActivity],有一个string型[In 参数]myIn在[Execute]方法中打印myIn的值并修改myIn的值后再次打印

    2.在xaml工作流中添加一个string型[myVariable]变量

    3. 在xaml工作流中添加一个[Assign],为[myVariable]变量赋值

    4. 在xaml工作流中添加[InChangeActivity], [InChangeActivity.myIn]绑定到[myVariable]变量

    5. 在xaml工作流中添加[WriteLine],打印[myVariable]变量值

    public sealed class InChangeActivity : CodeActivity
        {
            // 定义一个字符串类型的活动输入参数
            public InArgument<string> myIn { get; set; }
    
            // 如果活动返回值,则从 CodeActivity<TResult>
            // 派生并从 Execute 方法返回该值。
            protected override void Execute(CodeActivityContext context)
            {
                // 获取 Text 输入参数的运行时值
                string s1 = context.GetValue(this.myIn);
                System.Console.WriteLine("Input Value is:{0}", s1);
    
                context.SetValue(myIn, Guid.NewGuid().ToString());
    
                string s2 = context.GetValue(this.myIn);
                System.Console.WriteLine("Modify internal:{0}", s2); 
            }
        }

    宿主

    static void Main(string[] args)
            {
                WorkflowInvoker.Invoke(new InChangeWorkflow());
            }

    结果

    [Out 参数] 关联变量值无法传入内部,内部参数修改时,会更新其关联的变量

    说明:

    1.定义一个[OutChangeActivity],有一个string型[Out 参数]myOut在[Execute]方法中打印myOut的值并修改myOut的值后再次打印

    2.在xaml工作流中添加一个string型[myVariable]变量

    3. 在xaml工作流中添加一个[Assign],为[myVariable]变量赋值

    4. 在xaml工作流中添加[OutChangeActivity], [OutChangeActivity.myOut]绑定到[myVariable]变量

    5. 在xaml工作流中添加[WriteLine],打印[myVariable]变量值

    public sealed class OutChangeActivity : CodeActivity
        {
            public OutArgument<string> myOut { get; set; }
    
            // 如果活动返回值,则从 CodeActivity<TResult>
            // 派生并从 Execute 方法返回该值。
            protected override void Execute(CodeActivityContext context)
            {
                string s1 = context.GetValue(this.myOut);
                System.Console.WriteLine("Input Value:{0}", s1);
    
                // 
                context.SetValue(myOut, Guid.NewGuid().ToString());
    
                // 
                string s2 = context.GetValue(this.myOut);
                System.Console.WriteLine("Modify internal:{0}", s2); 
            }
        }

    宿主

    static void Main(string[] args)
            {
                WorkflowInvoker.Invoke(new OutChangeWorkflow());
            }

    结果

    [In/Out 参数]关联变量值可传入内部;内部参数修改时,会更新其关联的变量

    说明:

    1.定义一个 [InOutChangeActivity],有一个string型[InOut 参数]myInOut在[Execute]方法中打印myInOut的值并修改myInOut的值后再次打印

    2.在xaml工作流中添加一个string型[myVariable]变量

    3. 在xaml工作流中添加一个[Assign],为[myVariable]变量赋值

    4. 在xaml工作流中添加[InOutChangeActivity], [InOutChangeActivity.myInOut]绑定到[myVariable]变量

    5. 在xaml工作流中添加[WriteLine],打印[myVariable]变量值

    public sealed class InOutChangeActivity : CodeActivity
        {
            public InOutArgument<string> myInOut { get; set; }
    
            // 如果活动返回值,则从 CodeActivity<TResult>
            // 派生并从 Execute 方法返回该值。
            protected override void Execute(CodeActivityContext context)
            {
                string s1 = context.GetValue(this.myInOut);
                System.Console.WriteLine("Input Value:{0}", s1);
    
                // 
                context.SetValue(myInOut, Guid.NewGuid().ToString());
    
                // 
                string s2 = context.GetValue(this.myInOut);
                System.Console.WriteLine("Modify internal:{0}", s2); 
            }
        }

    宿主

    static void Main(string[] args)
            {
                WorkflowInvoker.Invoke(new InOutChangeWorkflow());
            }

    结果

    参考:http://tech.ddvip.com/2009-11/1259285719139913.html

  • 相关阅读:
    nodejs微服务
    node 操作文件流 fs 同步与异步 流式文件的写入与读取
    node判断文件目录是否存在
    Nodejs 使用 Chrome DevTools 调试 --inspect-brk
    使用ovftool工具实现exsi上主机的导入导出
    redis哨兵
    LVS+Nginx
    nginx的proxy代理缓存
    flanneld启动报错Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
    flanneld启动报错Failed to create SubnetManager: parse first path segment in URL cannot contain colon
  • 原文地址:https://www.cnblogs.com/vincentDr/p/3342871.html
Copyright © 2011-2022 走看看