0

在Windows工作流基础序列工作流中,如何根据一定条件使用调用方法标签?如何在XAML Windows工作流基础中有条件地使用InvokeMethod

例如,

<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> 

想,我所说的上述活动,所有的调用方法将被触发。

但是,什么是需要的,是一样的东西,

<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> 

有人可以给一些知道如何去这件事吗?

+0

你手工编辑的.xaml文件? – Joao

+0

是的,对于原型,我将手动编辑XAML。后来它会被推广。 –

回答

0

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

<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> 
+0

If的命名空间是什么? –

+0

它位于[System.Activities.Statements]命名空间中。 – ajawad987

相关问题