Rising

自我学习记录,方便使用时查找。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

示例来自microsoft windows workflow foundation 4.0 cookbook P31

 

1.  Create a workfow project:
Create a new Workfow Console Application under the Chapter01 solution and
name the project as LoadUpWorkflowFromXML.
2.  Author a workfow:
Author the Workflow1.xaml fle; this workfow will print a string to console as shown
in the following screenshot:
3.  Create code to load up the workfow instance from an XAML string:
Open Program.cs fle and change code as follow:
using System;
using System.Activities;
using System.Activities.Statements;
using System.IO;
using System.Collections;
using System.Text;
using System.Activities.XamlIntegration;
namespace LoadUpWorkflowFromXML {
    class Program {
        static void Main(string[] args) {
            string filePath=           @"C:\WF4Cookbook\Chapter01\
LoadUpWFFromXML\Workflow1.xaml";
            string tempString="";
            StringBuilder xamlWFString = new StringBuilder();
            StreamReader xamlStreamReader =
                new StreamReader(filePath);
            while (tempString != null){
                tempString = xamlStreamReader.ReadLine();
                if (tempString != null) {
                    xamlWFString.Append(tempString);
                }
            }
            Activity wfInstance = ActivityXamlServices.Load(
                new StringReader(xamlWFString.ToString()));
            WorkflowInvoker.Invoke(wfInstance);
        }
    }
}
 

posted on 2012-09-11 10:10  Rising  阅读(222)  评论(0编辑  收藏  举报