示例#1
0
        private bool Exec(bool first)
        {
            if (first)
            {
                //If First step of iteration failed, stop & return false
                if (!First())
                {
                    return(false);
                }
            }
            else
            {
                //If one of the subsequent steps of iteration failed, stop & return false
                if (!Next())
                {
                    return(false);
                }

                //Peek command has no way of knowing that it has reached end of queue until it tries to read next message
                //therefore even though Next method returns true indicating that command was complete successfully,
                //but no message was actually read, for this case need to check if command has changed its status to Complete
                //and return true if it did, in order to avoid execution of child commands one extra time
                if (_complete)
                {
                    return(true);           //TDB Use _comlpete or Complete()?
                }
            }

            //Iterate over children and execute all for each iteration of the parent
            foreach (CommandBaseEx command in _children)
            {
                //Pass Message object to each child, general case, some commands may not need that
                command.Message = this.Message;

                if (!CommandBaseEx.Run(command))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public static bool Run(CommandBaseEx command)
        {
            //If First step of iteration failed return failure
            if (!command.Exec(true))
            {
                return(false);
            }

            //Iterate while complete (one steps commands wont even enter the loop)
            while (!command.Complete())
            {
                //Run Next, return false if failed
                if (!command.Exec(false))
                {
                    return(false);
                }
            }

            //Return true if complete successfully
            return(true);
        }
示例#3
0
 public void AddChild(CommandBaseEx command)
 {
     _children.Add(command);
 }