public static IElement CreateControlFlowElement(XmlNode node, ControlFlowType type) { IElement _return = null; switch (type) { case ControlFlowType.If: _return = new IfElement(node, CreateElements(node.SelectNodes(DO_NODE)), CreateElements(node.SelectNodes(ELSE_NODE))); break; case ControlFlowType.ForEach: _return = new ForEachElement(node, CreateElements(node.SelectNodes(DO_NODE))); break; case ControlFlowType.Repeat: _return = new RepeatElement(node, CreateElements(node.SelectNodes(DO_NODE))); break; case ControlFlowType.While: break; case ControlFlowType.Switch: break; default: break; } return(_return); }
private void executeRepeat(RepeatElement repeatNode) { string repeatFor = repeatNode.getAttribute(AttributeConstants.TIMES).getValue().ToString(); Int32 repeatTimes = 0; try { Int32.TryParse(repeatFor, out repeatTimes); } catch (Exception) { throw new Exception("repeat time must be a number!"); } for (int i = 0; i < repeatTimes; i++) { IList <IElement> doNodes = repeatNode.DoNodes; runRecursive(doNodes); } }