예제 #1
0
        // Wrapper=false to keek CommandTrace updates

        protected override void DoCommandAction()
        {
            // internal
            bool exists = Objects.VariableManager.Instance.IsSet(Variable);

            // environement
            string value = Environment.GetEnvironmentVariable(Variable);

            if (value != null)
            {
                exists = true;
            }

            CommandStringParser parser = new CommandStringParser(exists ? Then : Else);

            foreach (string cmdString in parser.Parse())
            {
                Command cmd        = null;
                string  errorDescr = "";
                parser.ParseCommand(cmdString, true, out cmd, out errorDescr);
                // only the alias it self shall appear in the command trace
                cmd.UpdateCommandTrace = false;
                CommandExecuter.Instance.Execute(cmd);
            }
        }
예제 #2
0
        private void RunCommandsFromParser(CommandStringParser parser)
        {
            CommandExecutionContext context = new CommandExecutionContext();

            foreach (string cmdString in parser.Parse())
            {
                Command parsedCmd = null;
                string  errorDescr;
                bool    valid = parser.ParseCommand(cmdString, false, out parsedCmd, out errorDescr);
                if (valid)
                {
                    context.Parsed(cmdString, parsedCmd);
                }
                else
                {
                    // forward parse error to hooks
                    foreach (CommandHook hook in m_hooks)
                    {
                        hook.ParseError(cmdString, errorDescr);
                    }
                    // we can not execute this command
                    continue;
                }
            }

            context.SetLabels();
            context.ExecuteAll();
        }
예제 #3
0
        protected override void DoCommandAction()
        {
            CommandStringParser parser = new CommandStringParser(Commands);

            foreach (string cmdString in parser.Parse())
            {
                Command cmd        = null;
                string  errorDescr = "";
                parser.ParseCommand(cmdString, true, out cmd, out errorDescr);
                // only the alias it self shall appear in the command trace
                cmd.UpdateCommandTrace = false;
                string errorDescription = "";
                parser.SetParamters(cmd, true, m_overriddenDefaults, ref errorDescription);
                CommandExecuter.Instance.Execute(cmd);
            }
        }
예제 #4
0
        /// <summary>
        /// No labels here!!
        /// </summary>
        public void ExecuteWithOutContext(string commandString)
        {
            CommandStringParser parser = new CommandStringParser(commandString);

            foreach (string cmdString in parser.Parse())
            {
                Command parsedCmd = null;
                string  errorDescr;
                bool    valid = parser.ParseCommand(cmdString, true, out parsedCmd, out errorDescr);
                if (valid)
                {
                    Execute(parsedCmd);
                }
                else
                {
                    throw new ArgumentException(errorDescr);
                }
            }
        }
예제 #5
0
        protected override void DoCommandAction()
        {
            ExpressionParser ep   = new ExpressionParser();
            int  evaluationResult = 0;
            bool valid            = ep.Evaluate(Condition, out evaluationResult);

            if (!valid)
            {
                throw new ArgumentException("Condition" + Condition + " is not a valid arithmetic expression");
            }

            CommandStringParser parser = new CommandStringParser(evaluationResult != 0 ? Then : Else);

            foreach (string cmdString in parser.Parse())
            {
                Command cmd        = null;
                string  errorDescr = "";
                parser.ParseCommand(cmdString, true, out cmd, out errorDescr);
                // only the alias it self shall appear in the command trace
                cmd.UpdateCommandTrace = false;
                CommandExecuter.Instance.Execute(cmd);
            }
        }