将InArguments绑定到子活动 [英] Binding InArguments to child activities

查看:70
本文介绍了将InArguments绑定到子活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在设计器中创建了一个活动(称为MyWorkflow),该活动具有InArgument< bool>.名为IsClean.我将自定义CodeActivity添加到了序列中,该序列还具有InArgument< bool>.名为IsClean.在设计器中,我将代码活动的IsClean参数设置为IsClean,该参数应该是MyWorkflow的参数.

I have an activity created (call it MyWorkflow) in the designer that has an InArgument<bool> named IsClean.  I added a custom CodeActivity to the sequence that also has an InArgument<bool> named IsClean.  In the designer, I set the IsClean argument of the code activity to be IsClean, which should be the argument from MyWorkflow.


推荐答案

Jason

我已经尝试用相对较新的方式来对此进行复制,并且我的解决方案可以构建并正常运行.我无法重现此错误.您使用的是哪个版本?

自上次发行以来,此问题可能已得到修复.

这是我的代码活动和工作流程:

    公共密封类CodeActivity1:CodeActivity
{
       //定义字符串类型的活动输入参数
       public InArgument< bool>文字{get;放; }

Hi Jason,

I've tried to repro this with relatively recent bits, and my solution builds and runs properly.  I haven't been able to reproduce this error.  Which build are you using?  It is possible that this has been fixed since the last release.

For reference, here is my code activity and workflow:

    public sealed class CodeActivity1 : CodeActivity
    {
        // Define an activity input argument of type string
        public InArgument<bool> Text { get; set; }

       //如果您的活动返回值,则从CodeActivity< TResult>
派生//,然后从Execute方法返回值.
      受保护的重写void Execute(CodeActivityContext上下文)
{
                       //获取Text输入参数的运行时值
布尔文本= context.GetValue(this.Text);
Console.WriteLine(text.ToString());
        }
    }

<活动mc:Ignorable ="sap" x:Class ="CSDeb.Workflow1"; xmlns =< http://schemas.microsoft.com/netfx/2009/xaml/activities " ; xmlns:local ="clr-namespace:CSDeb" xmlns:mc =" http://schemas.openxmlformats.org/markup-compatibility/2006 "xmlns:mv ="clr-namespace:Microsoft.VisualBasic; assembly = System" xmlns:mva ="clr-命名空间:Microsoft.VisualBasic.Activities; assembly = System.Activities" xmlns:s ="clr-namespace:System; assembly = mscorlib" xmlns:s1 ="clr-namespace:System; assembly = System"; xmlns:s2 ="clr-namespace:System; assembly = System.Xml" xmlns:s3 ="clr-namespace:System; assembly = System.Core" xmlns:s4 ="clr-namespace:System; assembly = System.ServiceModel" xmlns:sa ="clr-namespace:System.Activities; assembly = System.Activities" xmlns:sad ="clr-命名空间:System.Activities.Debugger; assembly = System.Activities" xmlns:sap =" http://schemas.microsoft.com/netfx/2009/xaml/activities/演示文稿" xmlns:scg =" clr-namespace:System.Collections.Generic; assembly = System"; xmlns:scg1 ="clr-命名空间:System.Collections.Generic; assembly = System.ServiceModel" xmlns:scg2 ="clr-命名空间:System.Collections.Generic; assembly = System.Core" xmlns:scg3 ="clr-namespace:System.Collections.Generic; assembly = mscorlib" xmlns:sd ="clr命名空间:System.Data; assembly = System.Data" xmlns:sl ="clr-namespace:System.Linq; assembly = System.Core" xmlns:st ="clr-namespace:System.Text; assembly = mscorlib" xmlns:x =" http://schemas.microsoft.com/winfx/2006/xaml > ;
  < x:成员>
    < x:属性名称=文本";类型="InArgument(x:布尔)". />
  </x:成员>
  < sap:VirtualizedContainerService.HintSize> 273,349</sap:VirtualizedContainerService.HintSize>
  < mva:VisualBasic.Settings>内部实现的程序集引用和导入的名称空间</mva:VisualBasic.Settings>
  <序列可悲:XamlDebuggerXmlReader.FileName ="c:\ users \ btslabs \ documents \ visual studio 2010 \ Projects \ CSDeb \ CSDeb \ Workflow1.xaml" sap:VirtualizedContainerService.HintSize ="233,309">
< Sequence.Variables>
     <变量x:TypeArguments ="x:String"名称="variable1" />
    </Sequence.Variables>
    < sap:WorkflowViewStateService.ViewState>
     < scg3:Dictionary x:TypeArguments ="x:String,x:Object">
       < x:布尔值x:Key =已扩展" True</x:布尔值>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    < local:CodeActivity1 sap:VirtualizedContainerService.HintSize ="211,22"文字="[[文字]"" />
    < Delay Duration =="[New TimeSpan(0,0,20)]" sap:VirtualizedContainerService.HintSize ="211,22" />
    < WriteLine sap:VirtualizedContainerService.HintSize ="211,61"文字="hello" />
  </Sequence>
</Activity>

       静态void Main(string [] args)
{
                      字典<字符串,对象> myDictionary =新字典< string,object>();
myDictionary.Add("Text",false);
WorkflowInvoker.Invoke(new Workflow1(),myDictionary);
}

希望有帮助,
-Eric


        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            bool text = context.GetValue(this.Text);
            Console.WriteLine(text.ToString());
        }
    }

<Activity mc:Ignorable="sap" x:Class="CSDeb.Workflow1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:local="clr-namespace:CSDeb" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:s4="clr-namespace:System;assembly=System.ServiceModel" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Members>
    <x:Property Name="Text" Type="InArgument(x:Boolean)" />
  </x:Members>
  <sap:VirtualizedContainerService.HintSize>273,349</sap:VirtualizedContainerService.HintSize>
  <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
  <Sequence sad:XamlDebuggerXmlReader.FileName="c:\users\btslabs\documents\visual studio 2010\Projects\CSDeb\CSDeb\Workflow1.xaml" sap:VirtualizedContainerService.HintSize="233,309">
    <Sequence.Variables>
      <Variable x:TypeArguments="x:String" Name="variable1" />
    </Sequence.Variables>
    <sap:WorkflowViewStateService.ViewState>
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <local:CodeActivity1 sap:VirtualizedContainerService.HintSize="211,22" Text="[Text]" />
    <Delay Duration="[New TimeSpan(0, 0, 20)]" sap:VirtualizedContainerService.HintSize="211,22" />
    <WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="hello" />
  </Sequence>
</Activity>

        static void Main(string[] args)
        {
            Dictionary<string, object> myDictionary = new Dictionary<string, object>();
            myDictionary.Add("Text", false);
            WorkflowInvoker.Invoke(new Workflow1(), myDictionary);
        }

Hope this helps,
-Eric



这篇关于将InArguments绑定到子活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆