/// <summary> /// </summary> /// <param name="levelCounter"></param> /// <param name="terminate"></param> private void LoadEquationGroup(ref List <string> fieldsUsedInRule) { int topLevel = 0; string root = "rule"; string repeater = "parentheses"; string path = GetRecursiveLevelledPath(root, repeater, topLevel); string parenthesesXpath = path + "[@level='" + topLevel.ToString() + "']"; XmlNodeList listSiblingsAtThisLevel = _ruleSetDefinitionXml.SelectNodes(parenthesesXpath); EquationGroup equationGroup = new EquationGroup(_ruleSetDefinitionXml, _ruleSetMetaDataDefinition, ref fieldsUsedInRule); //this cannot be a square bracket grouping because it is the top level, but the top level can contain square bracket groupings //this is the default on the equation group object set to false just for clarity of intention equationGroup.IsSquareBracketGrouping = false; this._finalEquationGroup = equationGroup; this._actionsStack = _finalEquationGroup.ActionStackableItemsStack; equationGroup.CopyStack(); }
private void WalkUpFromLastChild(XmlNode node) { if (node == null) { return; } else if (node.Name == "rule") { return; } else { //add this one XmlNode previousSiblingForNextProcessing = null; if (node.Name == "action") { Action action = new Action(node); this.ActionStackableItemsStack.Push(action); previousSiblingForNextProcessing = node.PreviousSibling; } if (node.Name == "clause") { Clause clause = new Clause(node); this.ConditionStackableItemsStack.Push(clause); previousSiblingForNextProcessing = node.PreviousSibling; } if (node.Name == "parentheses") { EquationGroup equationGroup = new EquationGroup(_ruleSetMetaDataDefinition, ref _fields); equationGroup.IsSquareBracketGrouping = IsSquareBrackets(node); if (equationGroup.IsSquareBracketGrouping) { LoadSquareBracketGroupingProperties(node); } equationGroup.WalkUpFromLastChild(node.LastChild); this.ConditionStackableItemsStack.Push(equationGroup); previousSiblingForNextProcessing = node.PreviousSibling; } if (node.Name == "value") { XmlNode valueNode = node; XmlNode operatorNode = node.PreviousSibling; XmlNode fieldNode = operatorNode.PreviousSibling; Equation equation = new Equation(fieldNode, operatorNode, valueNode, _ruleSetMetaDataDefinition); if (_fields != null) { if (equation.FieldProperty.MetaDataField is EnumerableCollectionMemberField) { _fields.Add(((EnumerableCollectionMemberField)equation.FieldProperty.MetaDataField).MemberOfCollection); } else if (equation.FieldProperty.MetaDataField is DictionaryCollectionMemberField) { _fields.Add(((DictionaryCollectionMemberField)equation.FieldProperty.MetaDataField).MemberOfCollection); } else { _fields.Add(equation.FieldProperty.PropertyName); } } this.ConditionStackableItemsStack.Push(equation); previousSiblingForNextProcessing = fieldNode.PreviousSibling; } WalkUpFromLastChild(previousSiblingForNextProcessing); //call this function recursively with previous sibling } return; }