问题描述
我是工作流基础的新手,我使用的是工作流基础 4.5 (VS2012 RC).我想构建一个工作流,我可以在其中添加/删除运行时的规则.所以我想在一个单独的 .rules 文件上使用一组规则,并在需要时更改它.
I am new to workflow foundation and I am using workflow foundation 4.5 (VS2012 RC). I want to build a workflow where i can add/remove rules on the run time. So i was thinking of using a set of rules on a separate .rules file and change this as and when I need it.
但是,我在 VS2012 上找不到这个.有什么办法可以在工作流基础 4.5 中使用动态规则吗?
However, i can't find this on VS2012. Is there any way that I can uses dynamic rules in workflow foundation 4.5?
推荐答案
此代码块应允许您动态加载和执行规则.您可以查看本文的其余部分,其中还将向您展示如何动态保存这些文件,此处.
This code block should allow you to load and execute your rules dynamically. You can see the rest of this post, which will also show you how to save those files dynamically, here.
static RuleSet Load(string filename)
{
XmlTextReader reader = new XmlTextReader(filename);
WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();
object results = serializer.Deserialize(reader);
RuleSet ruleset = (RuleSet)results;
if (ruleset == null)
{
Console.WriteLine("The rules file " + filename + " does not appear to contain a valid ruleset.");
}
return ruleset;
}
这篇关于如何在工作流基础 4.5 (VS2012) 中创建 .rules 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!