Пример #1
0
        /// <summary>
        /// Runs the parsed command.
        /// </summary>
        /// <param name="command">Parsed Command.</param>
        private void RunCommand(SMParsedCommand command)
        {
            this.UpdateLastRunCommand();

            // Get the Class name of the command class for use in the ClassBuilder
            string commandClassName = command.Command.CommandClass.Split('.').Last();

            // Get class instance from ClassBuilder to run the command with
            ClassBuilder cb           = new ClassBuilder(commandClassName, this.UserID);
            object       commandClass = cb.GetClassInstance();

            // If null returned by ClassBuilder, run the command with the CommandClass name
            // this lets UserCallFuncArray handle object instantiation.
            if (commandClass == null)
            {
                Utils.CallUserFuncArray(
                    command.Command.CommandClass,
                    command.Command.CommandMethod,
                    command.Parameters
                    );
            }
            // Rm the command using the object instance returned by the ClassBuilder.
            else
            {
                Utils.CallUserFuncArray(
                    commandClass,
                    command.Command.CommandMethod,
                    command.Parameters
                    );
            }
        }
Пример #2
0
        /// <summary>
        /// Builds and return the SMParsedCommand object based on the users input.
        /// </summary>
        /// <returns>SMParsedCommand object.</returns>
        public SMParsedCommand GetParsedCommand()
        {
            SMParsedCommand parsedCmd = new SMParsedCommand();

            parsedCmd.CommandName = this.cmdName;
            parsedCmd.Command     = this.cmd;
            parsedCmd.Parameters  = this.GetCommandParameters();

            return(parsedCmd);
        }
Пример #3
0
        /// <summary>
        /// Runs the parsed command.
        /// </summary>
        /// <param name="command">Parsed Command.</param>
        private void RunCommand(SMParsedCommand command)
        {
            object result;

            this.UpdateLastRunCommand();

            // Get the Class name of the command class for use in the ClassBuilder
            string commandClassName = command.Command.CommandClass.Split('.').Last();

            // Get class instance from ClassBuilder to run the command with
            ClassBuilder cb           = new ClassBuilder(commandClassName, this.UserID);
            object       commandClass = cb.GetClassInstance();

            // If null returned by ClassBuilder, run the command with the CommandClass name
            // this lets UserCallFuncArray handle object instantiation.
            if (commandClass == null)
            {
                result = Utils.CallUserFuncArray(
                    command.Command.CommandClass,
                    command.Command.CommandMethod,
                    command.Parameters
                    );
            }
            // Run the command using the object instance returned by the ClassBuilder.
            else
            {
                result = Utils.CallUserFuncArray(
                    commandClass,
                    command.Command.CommandMethod,
                    command.Parameters
                    );
            }

            if (result != null && result.GetType() == typeof(SMCommandException))
            {
                this.SendMessage(ResponseFormatterFactory.Get().Italic(this.GetCommandFailureMsg()));
            }
        }