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

相關問題