博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WF4实例对象转化成XAML文档
阅读量:6083 次
发布时间:2019-06-20

本文共 1160 字,大约阅读时间需要 3 分钟。

示例来自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());
        }
    }
}
 

转载于:https://www.cnblogs.com/Rising/archive/2012/09/11/2679741.html

你可能感兴趣的文章
阅读JDK8 CopyOnWriteArraySet应该了解什么
查看>>
Objective-c和Java下DES加密保持一致的方式
查看>>
RequireJS + AngularJS Seed 13 _Grunt-plugin
查看>>
python3统计文件中字符或字符串出现的次数,支持同时多个字符串
查看>>
Redis 的 8 大应用场景!
查看>>
nginx 安装
查看>>
Django学习笔记(1)---引入静态资源
查看>>
鸟哥的Linux笔记----20180113
查看>>
quick-cocos2d-x开发工具sublime text及其强力插件QuickXDev
查看>>
CURL模拟HTTP浏览器动作常用命令-作弊投票利器
查看>>
mysql集群方案整理之Galera Cluster简介
查看>>
C# 文件上传类
查看>>
interlliJ idea 与 sonarQube 的集成使用
查看>>
spring注解入门
查看>>
git误上传了一个非常大的文件,如何删除
查看>>
unbind从每个匹配的元素中删除绑定的事件.
查看>>
Hive Export和Import介绍及操作示例
查看>>
需跟进的
查看>>
Zend Opcache与XCache之间共存与效率问题
查看>>
代码生成利器:IDEA 强大的 Live Templates
查看>>