可以看到4.0支持的活动类型不仅更多,而且分类更细致。不仅在controlFlow和原始类型中提供了基础的活动,用来定制基本的流程,而且在FlowChart里面提供了能更加灵活的定制流程的活动类型,同时还提供用于消息、事务、错误处理等功能的活动
接下来看看引用的类库以及项目文件的目录结构:
.Net3.5中引用了以下类库:
System.Workflow.Activities:定义了工作流可以创建、允许的活动集合
System.Workflow.ComponentModel:提供创建活动、工作流的基类、接口以及核心建模构造
System.Workflow.Runtime:提供一些类和接口可以控制工作流运行时引擎以及流程实例的执行
默认创建的工作流是Workflow1.cs,对于设计完的流程是用类文件的形式进行描述,即Workflow1.designer.cs,执行代码放到Workflow1.cs中。
通过ViewCode可以看到两个类的代码为:
public sealed partial class Workflow1 : SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
}
//Workflow1.designer.cs
partial class Workflow1
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
[System.CodeDom.Compiler.GeneratedCode("", "")]
private void InitializeComponent()
{
this.Name = "Workflow1";
}
#endregion
}
.NET4.0中WorkFlow引用了以下类库:
System.Activities:包含创建和使用活动所需的所有类。使用此命名空间中的类可以定义活动、输入输出数据和变量
System.ServiceModel:包含用于生成服务和客户端应用程序所需的类、枚举和接口,这些类、枚举和接口可以用于生成大范围的分布式程序
System.ServiceModel.Activities:使用此命名空间中的类可以从工作流接受消息,或者向工作流发送消息,定义工作流服务的时候可以使用这些活动
默认创建的是Workflow1.xaml,定义完的流程是用xml的方式进行描述。
通过ViewCode,我们可以看到WorkFlow1.xaml中的内容:
x:Class="WFConsoleAppTest.Workflow1"
sap:VirtualizedContainerService.HintSize="240,240"
mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
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: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=System"
xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core"
xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib"
xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
xmlns:sl="clr-namespace:System.Linq;assembly=System.Core"
xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" />