• WF4.0 Beta1 变量 Variables


     

    只有具备[Variables]属性的Activity才可以定义变量

    [Variables] 的数据类型为System.Collections.ObjectModel.Collection<System.Activities.Variable>

     

    变量添加

    在WF设计器中添加

     

    变量存放在所在[Activity]的内部,

     

    <p:Activity mc:Ignorable=""

    x:Class="WorkflowConsoleApplication3.Sequence1"

    xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/design"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities"

    xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:w="clr-namespace:WorkflowConsoleApplication3;assembly=WorkflowConsoleApplication3"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <p:Sequence >

    <w:myElement>

    <w:myElement.Variables>

    <p:Variable x:TypeArguments="x:String" Default="[&quot;i am wxd&quot;]" Name="wxd" />

    </w:myElement.Variables>

    </w:myElement>

    </p:Activity>

     

    在定义变量的[Activity]内部的[Activity]可以访问变量,在定义变量的[Activity]外部的[Activity]无法访问变量

     

    无法通过启动传参方式为[变量]赋值.无法在流程完成事件中接收[变量]的值

     

    定义具有[Variables]属性的Activity

    自定义Activity

    public class myNative :NativeActivity

    {

     

    private Collection<Variable> variables;

    private Variable<int> lastIndexHint;

    public myNative()

    {

    this.variables = new WorkflowElement.DesignTimeAwareCollection<Variable>(this);

    this.lastIndexHint = new Variable<int> { Modifiers = VariableModifiers.SuppressTracking };

    }

     

    protected override void OnGetEnvironmentVariables(IList<Variable> variables)

    {

    for (int i = 0; i < this.Variables.Count; i++)

    {

    variables.Add(this.Variables[i]);

    }

    }

     

    protected override void OnGetPrivateVariables(IList<Variable> variables)

    {

    variables.Add(this.lastIndexHint);

    }

     

    public Collection<Variable> Variables

    {

    get

    {

    return this.variables;

    }

    }

     

    protected override void Execute(ActivityExecutionContext context)

    {

    foreach (var v in variables)

    {

    System.Console.WriteLine("{0}:{1}",v.Name,v.Get(context));

     

    }

    }

    }

    流程

    宿主

     

    WorkflowInstance myInstance = new WorkflowInstance(new Sequence1());

     

    myInstance.Run();

     

    System.Console.Read();

    结果

     

  • 相关阅读:
    Eclipse创建Python工程
    MySQL python安装
    pip安装-python2.7.15
    接口测试-HTTP重点知识及 测试工具
    接口测试-基础
    关闭win10的自动更新功能
    高版本MySQL(5.7,5.8)的JDBC连接新问题
    错误:java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
    Idea SpringBoot工程提示 "Error running 'xxxx'": Command line is too long... 问题解决
    错误:23:36:21.161 [main] ERROR org.springframework.boot.SpringApplication
  • 原文地址:https://www.cnblogs.com/foundation/p/1495604.html
Copyright © 2020-2023  润新知