Beispiel #1
0
        private static BaseCommand CreateCommand(string cmd, string assemblyName)
        {
            string typeName = "";

            var    arr     = cmd.Split(':');
            string tempcmd = arr.Length > 1 ? arr[1] : arr[0];

            if (ZyGameBaseConfigManager.GameSetting.HasSetting)
            {
                typeName = ZyGameBaseConfigManager.GameSetting.GetGmCommandType(cmd);
                typeName = !string.IsNullOrEmpty(typeName) ? typeName : tempcmd + "Command";
            }
            else
            {
                CommandCollection cmdList    = ((GmSection)ConfigurationManager.GetSection(SectionName)).Command;
                CommandElement    cmdElement = cmdList[cmd];
                typeName = cmdElement != null ? cmdElement.TypeName : tempcmd + "Command";
            }

            string commandType = typeName;

            if (typeName.IndexOf(",") == -1)
            {
                commandType = string.Format("{0}.{1},{0}", assemblyName, typeName);
            }
            var type = Type.GetType(commandType, false, true);

            if (type != null)
            {
                return(type.CreateInstance <BaseCommand>());
            }
            return(ScriptEngines.ExecuteCSharp(string.Format("{0}.{1}", assemblyName, typeName)));
        }
Beispiel #2
0
        private static BaseCommand CreateCommand(string cmd)
        {
            CommandCollection cmdList    = ((GmSection)ConfigurationManager.GetSection(SectionName)).Command;
            CommandElement    cmdElement = cmdList[cmd];

            if (cmdElement == null)
            {
                throw new Exception("[" + cmd + "]找不到处理器");
            }

            return((BaseCommand)Activator.CreateInstance(Type.GetType(cmdElement.TypeName)));
        }