问题描述
我是新来的工作流程的基础,我使用工作流基础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?
推荐答案
这code座应该让你加载和动态执行的规则。你可以看到这个帖子的休息,这也将告诉你如何动态地保存这些文件,的。
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以.rules文件(VS2012)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!