예제 #1
0
        /// <summary>
        /// 运行GM命令解析
        /// </summary>
        /// <param name="userId">发送GM命令者</param>
        /// <param name="command">GM命令</param>
        /// <param name="assemblyName">指定解析的程序集</param>
        public static void Run(string userId, string command, string assemblyName = "")
        {
            try
            {
                var section = ConfigManager.Configger.GetFirstOrAddConfig <MiddlewareSection>();
                if (!section.EnableGM)
                {
                    return;
                }

                command = command != null?command.Trim() : string.Empty;

                string[] paramList = command.Split(new char[] { ' ' });
                if (paramList.Length < 1)
                {
                    return;
                }

                string cmd = paramList[0].Trim();
                if (cmd.Length > 3)
                {
                    cmd = cmd.Substring(3, cmd.Length - 3);
                }

                string[] args = new string[0];
                if (paramList.Length > 1)
                {
                    args = paramList[1].Split(new char[] { ',' });
                }
                BaseCommand baseCommand = null;
                if (string.IsNullOrEmpty(assemblyName))
                {
                    baseCommand = new ScriptCommand(cmd);
                }
                else
                {
                    baseCommand = CreateCommand(cmd, assemblyName);
                }
                if (baseCommand == null)
                {
                    return;
                }
                baseCommand.UserID = userId;
                baseCommand.ProcessCmd(args);
            }
            catch (Exception ex)
            {
                ErrorFormat(command, ex);
            }
        }
예제 #2
0
        /// <summary>
        /// 运行GM命令解析
        /// </summary>
        /// <param name="userId">发送GM命令者</param>
        /// <param name="command">GM命令</param>
        /// <param name="assemblyName">指定解析的程序集</param>
        public static void Run(string userId, string command, string assemblyName = "")
        {
            try
            {
                if (!EnableGM)
                {
                    return;
                }

                command = command != null ? command.Trim() : string.Empty;
                string[] paramList = command.Split(new char[] { ' ' });
                if (paramList.Length < 1)
                {
                    return;
                }

                string cmd = paramList[0].Trim();
                if (cmd.Length > 3)
                {
                    cmd = cmd.Substring(3, cmd.Length - 3);
                }

                string[] args = new string[0];
                if (paramList.Length > 1)
                {
                    args = paramList[1].Split(new char[] { ',' });
                }
                BaseCommand baseCommand = null;
                if (string.IsNullOrEmpty(assemblyName))
                {
                    baseCommand = new ScriptCommand(cmd);
                }
                else
                {
                    baseCommand = CreateCommand(cmd, assemblyName);
                }
                if (baseCommand == null)
                {
                    return;
                }
                baseCommand.UserID = userId;
                baseCommand.ProcessCmd(args);
            }
            catch (Exception ex)
            {
                ErrorFormat(command, ex);
            }
        }