这两个 XAML 在工作流基础上有什么区别?

What is the difference between these two XAML in workflow foundation?

遇到windows工作流基础中指定的两种XAML,我只想知道它们的区别。

类型 1。

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Activity mc:Ignorable="sap" x:Class="Microsoft.Samples.InvokeMethodUsage.Sequence1" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:msi="clr-namespace:Microsoft.Samples.InvokeMethodUsage;assembly=InvokeMethodUsage" xmlns:msi1="clr-namespace:Microsoft.Samples.InvokeMethodUsage;assembly=InvokeMethodUsage, Version=1.0.3516.24075, Culture=neutral, PublicKeyToken=null" 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: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=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Sequence sap:VirtualizedContainerService.HintSize="333.663333333333,3387.23666666666">
    <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>


    <WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Instance Method Call with Parameters&quot;]" />
<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>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Instance Method Call with Parameter Arrays&quot;]" />
<InvokeMethod DisplayName="Instance Method Call with Parameter Arrays" 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>
  <InArgument x:TypeArguments="x:String">["first item of the param array"]</InArgument>
  <InArgument x:TypeArguments="x:String">["second item of the param array"]</InArgument>
  <InArgument x:TypeArguments="x:String">["third item of the param array"]</InArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Instance Method Call with Parameters and Return Value&quot;]" />
<InvokeMethod DisplayName="Instance Method Call with Parameters and Return Value" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="InstanceMethodWithResult">
  <InvokeMethod.Result>
    <OutArgument x:TypeArguments="x:Int32">[resultValue]</OutArgument>
  </InvokeMethod.Result>
  <InvokeMethod.TargetObject>
    <InArgument x:TypeArguments="msi:TestClass">[New TestClass()]</InArgument>
  </InvokeMethod.TargetObject>
  <InArgument x:TypeArguments="x:Int32">20</InArgument>
  <InArgument x:TypeArguments="x:Int32">22</InArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[String.Format(&quot;....Result: {0}&quot;, resultValue)]" />
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Static Method Call with Parameters&quot;]" />
<InvokeMethod DisplayName="Static Method Call with Parameters" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="StaticMethod" TargetType="msi:TestClass">
  <InArgument x:TypeArguments="x:String">["My favorite number is"]</InArgument>
  <InArgument x:TypeArguments="x:Int32">42</InArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Generic Instance Method Call with Generic Parameters&quot;]" />
<InvokeMethod DisplayName="Generic Instance Method Call with Generic Parameters" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="GenericInstanceMethod">
  <InvokeMethod.GenericTypeArguments>
    <x:Type Type="x:String" />
  </InvokeMethod.GenericTypeArguments>
  <InvokeMethod.TargetObject>
    <InArgument x:TypeArguments="msi:TestClass">[New TestClass()]</InArgument>
  </InvokeMethod.TargetObject>
  <InArgument x:TypeArguments="x:String">["Hello world"]</InArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Generic Static Method Call with Two Generic Parameters&quot;]" />
<InvokeMethod DisplayName="Generic Static Method Call with Two Generic Parameters" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="GenericStaticMethod" TargetType="msi:TestClass">
  <InvokeMethod.GenericTypeArguments>
    <x:Type Type="x:String" />
    <x:Type Type="x:Int32" />
  </InvokeMethod.GenericTypeArguments>
  <InArgument x:TypeArguments="x:String">["Favorite number"]</InArgument>
  <InArgument x:TypeArguments="x:Int32">42</InArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Instance Method Call with Parameters by Reference&quot;]" />
<InvokeMethod DisplayName="Instance Method Call with Parameters by Rerefence" 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>
  <InOutArgument x:TypeArguments="x:String">[outParam]</InOutArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[String.Format(&quot;....out param changed to: {0}&quot;, outParam)]" />
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Async Instance Method Call&quot;]" />
<InvokeMethod DisplayName="Async Instance Method Call" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="AsyncMethodSample" RunAsynchronously="True">
  <InvokeMethod.TargetObject>
    <InArgument x:TypeArguments="msi:TestClass">[New TestClass()]</InArgument>
  </InvokeMethod.TargetObject>
  <InArgument x:TypeArguments="x:String">["Hello async"]</InArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Store a Value&quot;]" />
<InvokeMethod DisplayName="Store a Value in an Instance" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="StoreValue">
  <InvokeMethod.TargetObject>
    <InArgument x:TypeArguments="msi:TestClass">[varTestClass]</InArgument>
  </InvokeMethod.TargetObject>
  <InArgument x:TypeArguments="x:Int32">42</InArgument>
</InvokeMethod>
<WriteLine sap:VirtualizedContainerService.HintSize="299.663333333333,59.2766666666667" Text="[&quot;Get a Value&quot;]" />
<InvokeMethod DisplayName="Get a Value from an Instance" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="GetValue">
  <InvokeMethod.Result>
    <OutArgument x:TypeArguments="x:Int32">[resultValue]</OutArgument>
  </InvokeMethod.Result>
  <InvokeMethod.TargetObject>
    <InArgument x:TypeArguments="msi:TestClass">[varTestClass]</InArgument>
  </InvokeMethod.TargetObject>
</InvokeMethod>
<InvokeMethod DisplayName="Write a Blank Line to the Console" sap:VirtualizedContainerService.HintSize="299.663333333333,127.553333333333" MethodName="WriteLine" TargetType="s:Console">
  <InArgument x:TypeArguments="x:String">[String.Format("....the stored value is {0}", resultValue)]</InArgument>
</InvokeMethod> 
</Sequence>

类型 2。

<SequentialWorkflowActivity x:Class="myxmsapplication.Workflow2" x:Name="Workflow2" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">|
   <WhileActivity x:Name="whileActivity1">
          <WhileActivity.Condition>
                 <RuleConditionReference ConditionName="Condition1" />
          </WhileActivity.Condition>
          <IfElseActivity x:Name="ifElseActivity1">
                 <IfElseBranchActivity x:Name="ifElseBranchActivity1">
                       <IfElseBranchActivity.Condition>
                              <RuleConditionReference ConditionName="Condition2" />
                       </IfElseBranchActivity.Condition>
                       <CodeActivity x:Name="codeActivity1" ExecuteCode="codeActivity1_ExecuteCode" />
                 </IfElseBranchActivity>
                 <IfElseBranchActivity x:Name="ifElseBranchActivity2">
                       <IfElseBranchActivity.Condition>
                              <RuleConditionReference ConditionName="Condition3" />
                       </IfElseBranchActivity.Condition>
                       <CodeActivity x:Name="codeActivity2" ExecuteCode="codeActivity2_ExecuteCode" />
                 </IfElseBranchActivity>
          </IfElseActivity>
   </WhileActivity>

Observation

它与 XAML 中的数据无关,而是与结构有关。 前者的根标签是 Activity,它的子标签是 Sequence,而后者以宽名称 SequenceWorkflowActivity 开头。哪位工作流基础好的能解释下区别吗?

类型 1 中的 XAML 是 Windows Workflow Foundation 的 4.x 版本,而类型 2 样本是 3.x 版本。