如何在XAML Windows工作流基础中有条件地使用InvokeMethod

编程入门 行业动态 更新时间:2024-10-26 01:30:37
本文介绍了如何在XAML Windows工作流基础中有条件地使用InvokeMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Windows工作流基础序列工作流中,如何使用根据特定条件被调用的invoke方法标记?

In windows workflow foundation sequence workflow, How to use invoke method tags to be invoked based on certain condition?

例如,

<Sequence> <Sequence.Variables> <Variable x:TypeArguments="x:String" Default="[&quot;this is an out param&quot;]" Name="outParam" /> <Variable x:TypeArguments="x:Int32" Name="resultValue" /> <Variable x:TypeArguments="msi:TestClass" Default="[New TestClass()]" Name="varTestClass" /> </Sequence.Variables> <sap:WorkflowViewStateService.ViewState> <scg:Dictionary x:TypeArguments="x:String, s:Object"> <x:Boolean x:Key="IsExpanded">True</x:Boolean> </scg:Dictionary> </sap:WorkflowViewStateService.ViewState> <WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Instance method call&quot;]" /> <InvokeMethod DisplayName="Instance Method Call" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="InstanceMethod1"> <InvokeMethod.TargetObject> <InArgument x:TypeArguments="msi:TestClass">[New TestClass()]</InArgument> </InvokeMethod.TargetObject> </InvokeMethod> <InvokeMethod DisplayName="Instance Method Call with Parameters" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="InstanceMethod"> <InvokeMethod.TargetObject> <InArgument x:TypeArguments="msi:TestClass">[New TestClass()]</InArgument> </InvokeMethod.TargetObject> <InArgument x:TypeArguments="x:String">["My favorite number is"]</InArgument> <InArgument x:TypeArguments="x:Int32">42</InArgument> </InvokeMethod> </Sequence>

假设我调用上述活动,所有的invoke方法都将被触发.

Suppose, I call the above activity, all the invoke methods will be triggered.

但是需要的是类似的东西

But what is needed, is something like,

<Sequence> <Sequence.Variables> <Variable x:TypeArguments="x:String" Default="[&quot;this is an out param&quot;]" Name="outParam" /> <Variable x:TypeArguments="x:Int32" Name="resultValue" /> <Variable x:TypeArguments="msi:TestClass" Default="[New TestClass()]" Name="varTestClass" /> </Sequence.Variables> <sap:WorkflowViewStateService.ViewState> <scg:Dictionary x:TypeArguments="x:String, s:Object"> <x:Boolean x:Key="IsExpanded">True</x:Boolean> </scg:Dictionary> </sap:WorkflowViewStateService.ViewState> <WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Instance method call&quot;]" /> //If (stateArgument =="created") //{ <InvokeMethod DisplayName="Instance Method Call" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="InstanceMethod1"> <InvokeMethod.TargetObject> <InArgument x:TypeArguments="msi:TestClass">[New TestClass()]</InArgument> </InvokeMethod.TargetObject> </InvokeMethod> //} //else if(stateArguement == "running") //{ <InvokeMethod DisplayName="Instance Method Call with Parameters" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="InstanceMethod"> <InvokeMethod.TargetObject> <InArgument x:TypeArguments="msi:TestClass">[New TestClass()]</InArgument> </InvokeMethod.TargetObject> <InArgument x:TypeArguments="x:String">["My favorite number is"]</InArgument> <InArgument x:TypeArguments="x:Int32">42</InArgument> </InvokeMethod> //} </Sequence>

有人可以提出一些建议吗?

Can someone give some idea how to go about this?

推荐答案

您可以使用If活动(在命名空间System.Activities.Statements中)有条件地执行工作流的各个部分:

You can use the If activity (in namespace System.Activities.Statements) for conditionally executing pieces of a workflow:

<If DisplayName="Invoke something based on a conditional" sap2010:WorkflowViewState.IdRef="If_1"> <If.Condition> <InArgument x:TypeArguments="x:Boolean"> <mca:CSharpValue x:TypeArguments="x:Boolean">1 == 2</mca:CSharpValue> </InArgument> </If.Condition> <If.Then> <InvokeMethod sap2010:WorkflowViewState.IdRef="InvokeMethod_1" MethodName="WriteSomething" TargetType="local:MyStatics" /> </If.Then> <If.Else> <InvokeMethod sap2010:WorkflowViewState.IdRef="InvokeMethod_2" MethodName="WriteSomethingElse" TargetType="local:MyStatics" /> </If.Else> </If>

更多推荐

如何在XAML Windows工作流基础中有条件地使用InvokeMethod

本文发布于:2023-11-25 03:56:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628220.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作流   中有   条件   基础   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!