Exemplo n.º 1
0
 public static void InitRuleEngine(AbstractActionManager actionManager,
                                   AbstractCategoryManager categoryManager,
                                   AbstractConditionManager conditionManager,
                                   AbstractOperatorManager operatorManager)
 {
     s_actionManager    = actionManager;
     s_categoryManager  = categoryManager;
     s_conditionManager = conditionManager;
     s_operatorManager  = operatorManager;
 }
Exemplo n.º 2
0
 public static void InitRuleEngine(AbstractActionManager actionManager,
     AbstractCategoryManager categoryManager,
     AbstractConditionManager conditionManager,
     AbstractOperatorManager operatorManager)
 {
     s_actionManager = actionManager;
     s_categoryManager = categoryManager;
     s_conditionManager = conditionManager;
     s_operatorManager = operatorManager;
 }
Exemplo n.º 3
0
        private Rule ProcessRuleNode(XmlNode ruleNode)
        {
            // for name attribute
            string  nameString        = RuleFileConstants.DefaultRuleName;
            XmlNode nameAttributeNode = ruleNode.Attributes.GetNamedItem(
                RuleFileConstants.RulesElementRuleNameAttributeName);

            if (nameAttributeNode != null)
            {
                nameString = nameAttributeNode.InnerText;
            }

            // for category attribute
            string categoryString = ruleNode.Attributes.GetNamedItem(
                RuleFileConstants.RulesElementCategoryAttributeName).InnerText;
            AbstractCategoryManager categoryManager = RuleEngine.GetCategoryManager();
            ICategory category = categoryManager.GetCategory(categoryString);

            if (category == null)
            {
                throw new NoCategoryAttributeException(nameString);
            }

            // for action
            XmlNodeList actionList = ruleNode.SelectNodes(RuleFileConstants.ActionElementName);

            if (actionList.Count != 1)
            {
                throw new ActionNodeNumberException(nameString);
            }
            IAction action = ProcessActionNode(actionList[0]);

            // for condition
            XmlNodeList conditionList = ruleNode.SelectNodes(RuleFileConstants.ConditionElementName);

            if (conditionList.Count != 1)
            {
                throw new ConditionNodeNumberException(nameString);
            }
            ICondition condition = ProcessMatchNode(conditionList[0], nameString);

            return(new Rule(category, action, condition, nameString));
        }