Как условно использовать InvokeMethod в основе рабочего процесса XAML Windows

В рабочем процессе последовательности рабочего процесса Windows. Как использовать теги метода вызова для вызова на основе определенного условия?

Например,

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

Может кто-нибудь дать представление о том, как это сделать?


person jeffry copps    schedule 23.05.2016    source источник
comment
Вы редактируете файлы .xaml вручную?   -  person Joao    schedule 23.05.2016
comment
Да, для прототипа я буду редактировать XAML вручную. Позже она будет обобщена.   -  person jeffry copps    schedule 23.05.2016


Ответы (1)


Вы можете использовать активность If (в пространстве имен System.Activities.Statements) для условного выполнения частей рабочего процесса:

<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>
person ajawad987    schedule 23.05.2016
comment
Какое пространство имен для If? - person jeffry copps; 24.05.2016
comment
Он находится в пространстве имен [System.Activities.Statements]. - person ajawad987; 24.05.2016