Esempio n. 1
0
        private IEnumerable <string> ExecuteRuns()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(BatchRunFile);
            var root = doc.FirstChild;

            if (root.HasChildNodes)
            {
                foreach (XmlNode topLevelCommand in root.ChildNodes)
                {
                    if (topLevelCommand.LocalName.Equals("Run", StringComparison.InvariantCultureIgnoreCase))
                    {
                        string name = "Unnamed Run";
                        SetupRun(topLevelCommand, ref name);
                        yield return(name);
                    }
                    else
                    {
                        if (topLevelCommand.NodeType != XmlNodeType.Comment)
                        {
                            var commandName = topLevelCommand.LocalName;
                            Action <XmlNode> command;
                            if (!BatchCommands.TryGetValue(commandName.ToLowerInvariant(), out command))
                            {
                                throw new XTMFRuntimeException("We are unable to find a command named '" + commandName
                                                               + "' for batch processing.  Please check your batch file!\r\n" + topLevelCommand.OuterXml);
                            }
                            command.Invoke(topLevelCommand);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 private IEnumerable <string> CommandProcessor(XmlNode root)
 {
     if (root.HasChildNodes)
     {
         foreach (XmlNode topLevelCommand in root.ChildNodes)
         {
             if (topLevelCommand.LocalName.Equals("Run", StringComparison.InvariantCultureIgnoreCase))
             {
                 string name = "Unnamed Run";
                 SetupRun(topLevelCommand, ref name);
                 yield return(name);
             }
             else
             {
                 if (topLevelCommand.NodeType != XmlNodeType.Comment)
                 {
                     var commandName = topLevelCommand.LocalName;
                     if (!BatchCommands.TryGetValue(commandName.ToLowerInvariant(), out Action <XmlNode> command))
                     {
                         throw new XTMFRuntimeException(this, "We are unable to find a command named '" + commandName
                                                        + "' for batch processing.  Please check your batch file!\r\n" + topLevelCommand.OuterXml);
                     }
                     var initialCount = ExecutionStack.Count;
                     command.Invoke(topLevelCommand);
                     if (initialCount < ExecutionStack.Count)
                     {
                         var current = ExecutionStack.Pop();
                         foreach (var run in CommandProcessor(current))
                         {
                             yield return(run);
                         }
                     }
                 }
             }
         }
     }
 }