private XmlNode WriteConditionToXmlNode(ICondition condition) { string conditionName = condition.GetConditionDef().GetConditionName(); XmlElement conditionElement = m_doc.CreateElement(conditionName); if (condition is AbstractCompositeCondition) { if (condition is AbstractMultipleCondition) { AbstractMultipleCondition multipleCondition = condition as AbstractMultipleCondition; foreach (ICondition subCondition in multipleCondition.ConditionList) { conditionElement.AppendChild(WriteConditionToXmlNode(subCondition)); } } else { AbstractSingleCondition singleCondition = condition as AbstractSingleCondition; conditionElement.AppendChild( WriteConditionToXmlNode(singleCondition.ConditionList[0])); } } else { AbstractAtomicCondition atomicCondition = condition as AbstractAtomicCondition; conditionElement.SetAttribute(RuleFileConstants.Operator, atomicCondition.Operator.GetOperatorName()); conditionElement.SetAttribute(RuleFileConstants.Value, atomicCondition.Value); } return(conditionElement); }
private ICondition ProcessConditionNode(XmlNode conditionNode) { AbstractConditionManager conditionManager = RuleEngine.GetConditionManager(); ICondition condition = conditionManager.CreateCondition(conditionNode.Name); if (condition is AbstractCompositeCondition) { if (condition is AbstractMultipleCondition) { AbstractMultipleCondition multipleCondition = condition as AbstractMultipleCondition; foreach (XmlNode childConditionNode in conditionNode.ChildNodes) { ICondition childCondition = ProcessConditionNode(childConditionNode); multipleCondition.AppendCondition(childCondition); } return(multipleCondition); } else { AbstractSingleCondition singleCondition = condition as AbstractSingleCondition; ICondition childCondition = ProcessConditionNode(conditionNode.ChildNodes[0]); singleCondition.AppendCondition(childCondition); return(singleCondition); } } else { AbstractAtomicCondition atomicCondition = condition as AbstractAtomicCondition; string operatorName = conditionNode.Attributes[RuleFileConstants.Operator].InnerText; atomicCondition.Operator = RuleEngine.GetOperatorManager().GetOperator(operatorName); atomicCondition.Value = conditionNode.Attributes[RuleFileConstants.Value].InnerText; return(atomicCondition); } }