how to create a .rules file in workflow foundation 4.5 (VS2012)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 10:51:42

问题


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.

However, i can't find this on VS2012. Is there any way that I can uses dynamic rules in workflow foundation 4.5?


回答1:


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;
}


来源:https://stackoverflow.com/questions/11771332/how-to-create-a-rules-file-in-workflow-foundation-4-5-vs2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!