Rising

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

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

示例来自Microsoft Windows Workflow Foundation 4.0 Cookbook P29

1.  Create a workfow project:
Create a new Workfow Console Application under the Chapter01 solution and
name the project ConvertWFInstanceToXML. Delete the Workflow1.xaml fle
that is created by default.
2.  Write code to create the workfow and its host:
Open Program.cs fle and change the code as follows:
using System;
using System.Activities;
using System.Activities.Statements;
using System.Text;
using System.Xaml;
using System.Activities.XamlIntegration;
using System.IO;
namespace ConvertWFObjectToXML {
    class Program {
        static void Main(string[] args) {
            //Create a Workflow instance object             
ActivityBuilder ab = new ActivityBuilder();
            ab.Implementation = new Sequence()
            {
                Activities =
                {
                    new WriteLine{Text="Message from Workflow"}
                }
            };
            //Convert Workflow instance to xml string
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            XamlWriter xw =
                ActivityXamlServices.CreateBuilderWriter(
                new XamlXmlWriter(sw,
                                  new XamlSchemaContext()));
            XamlServices.Save(xw, ab);
            Console.WriteLine(sb.ToString());
        }
    }
}
 

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