指弹吉他完整教程,WF4教程第一弹

本文主要是总结自己学习《microsoft windows workflow foundation 4.0 cookbook》第一章的内容。下面给出本章程序的源代码,下载地址如下:Chapter01.rar。下面简要介绍解决方案Chapter01中所有项目。解决方案中的各个项目如下图所示
clip_image001WF4教程第一弹指弹吉他完整教程

1.Creating the first WF program:HelloWorkflow

HelloWorkflow is a Workflow Console Application. The workflow we created in WF Designer is actually an XML file. We can open Workflow1.xaml with an XML editor to check it.
In Visual Studio 2010 we can Right-click _disibledevent=>Workflow Console Application.
We can use Variable temporarily to store a value when a WF program is running. In this task,we will create a WF program that prints five numbers to the console in a loop. We will use the NumberCounter variable as a number counter.
在WF程序运行期间,我们可以通过变量(Variable来暂时保存一个值。
While we can use arguments to flow data into and out of a workflow, we use Variable to store data in a workflow. Every variable has its scope, and can be accessed by activities within its scope. Variable in WF4 is pretty much like variables in imperative language such as C#.

7.Running a WF program asynchronously

UseWorkflowApplication a Workflow Console Application.
In the previous tasks, we used the WorkflowInvoker.Invoke method to start a workflow instance _disibledevent=>, we can flow data into the workflow when it starts and out of the workflow when it ends. But how can we pass data from the caller into the workflow when it is executing?—Bookmark will help us to do this. In this task, we will create a MyReadLine activity using a bookmark.
可以通过参数InArgument, OutArgument, and InOutArgument来使得数据在工作流中流动。但是我们如何在工作流执行期间从调用程序向工作流传递数据呢。Bookmark可以帮助我们完成这样的任务。
In WF4, workflow is actually an Activity class. We could see "Workflow" as a conception from a macroeconomic viewpoint, while considering "Activity" as a development concept.
在WF4中,工作流实际上就是一个Activity类。我们可以将工作流理解为宏观上的概念,而活动则是开发上的概念。

9.Converting a WF program instance to XAML

ConvertWFInstanceToXML a Workflow Console Application.
In real applications, we would like to write and test WF programs in imperative code, while storing, running, and transmitting workflow as an XAML string or file. In this task, we will convert a WF program instance to an XAML string.
将工作流程序实例转换成XAML类型的字符串。
Consider the following code line:
 
XamlServices provides services for the common XAML tasks of reading XAML and writing an object graph, or reading an object and writing out an XAML file. This statement reads an ActivityBuilder object and writes XAML to an XamlWriter object.
We use ActivityBuilder as an activity wrapper so that the output XAML is a loadable workflow. In other words, if we save, say, a Sequence activity to an XamlWriter directly, then the output XML workflow will be unloadable for further use.

10.Loading up a WF program from an XAML file

LoadUpWorkflowFromXML a Workflow Console Application.
In this task, we will run a WF program by loading it from an XAML file.
在本实例中,通过加载XAML文件来运行工作流应用程序。

11.Testing a WF program with a unit test framework

UnitTestForWFProgram is a Test Project.
[TestClass] indicates it is a unit test class, whereas [TestMethod] indicates a test method. When the Test Project runs, the test method will be executed automatically.
[TestClass]表示这个一个单元测试类。[TestMethod]表示这是一个测试类。当测试项目运行的时候,测试方法会自动执行。

12.Debugging a WF program

DebugWFProgram a Workflow Console Application.
Tags:  弹弹堂强化教程 弹幕教程 弹弹堂教程 指弹吉他教程 指弹吉他完整教程

延伸阅读

最新评论

发表评论