Ejemplo n.º 1
0
        /// <summary>
        /// Processes the specified command object.
        /// </summary>
        /// <param name="commandObject">The command object.</param>
        /// <param name="processActionCommands">Indicates whether to process "action" commands or other commands.</param>
        private void Process(CommandObject commandObject, bool processActionCommands)
        {
            var commands = commandObject.GetCommands();

            foreach (var processor in this._commandHandlers.Where(c => c.Type == CommandHandlerType.Command && (!processActionCommands || c.Command == "action")))
            {
                processor.Handle(commands);
            }

            var args = commandObject.GetArgs();

            foreach (var processor in this._commandHandlers.Where(c => c.Type == CommandHandlerType.Args && (!processActionCommands || c.Command == "action")))
            {
                processor.Handle(args);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        internal override CommandObject Parse(string command)
        {
            var commandTree = new CommandObject();

            if (string.IsNullOrWhiteSpace(command))
            {
                commandTree.Add(string.Empty, null);
                return(commandTree);
            }

            RecursiveTryParse(string.Empty, command.Replace("{", " {"), commandTree);

            try
            {
                // only if this isn't json will 'exe' work
                commandTree.Add("exe", Path.GetFullPath(command));
            }
            catch
            {
                // do nothing
            }

            return(commandTree);
        }
Ejemplo n.º 3
0
 internal virtual void ProcessActions(CommandObject commandObject)
 {
     this.Process(commandObject, true);
 }
Ejemplo n.º 4
0
 internal virtual void ProcessNonActions(CommandObject commandObject)
 {
     this.Process(commandObject, false);
 }