コード例 #1
0
ファイル: BaseCommand.cs プロジェクト: zhukaixy/Scut
        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)));
        }
コード例 #2
0
ファイル: Language.cs プロジェクト: yunjoker/Scut
        /// <summary>
        /// Set language object.
        /// </summary>
        private static void SetLang(string typeName)
        {
            if (string.IsNullOrEmpty(typeName))
            {
                typeName = ConfigManager.Configger.GetFirstOrAddConfig <AppServerSection>().LanguageTypeName;
            }

            var obj = ScriptEngines.ExecuteCSharp(typeName);

            if (obj != null)
            {
                _instance = obj;
                return;
            }
            //get default lang
            typeName = ConfigManager.Configger.GetFirstOrAddConfig <AppServerSection>().LanguageTypeName;
            var type = Type.GetType(typeName, false, false);

            if (type != null)
            {
                _instance = type.CreateInstance();
            }
            else
            {
                TraceLog.WriteWarn("Can not find the corresponding language configuration,typeName:{0}", typeName);//By Seamoon
            }
        }
コード例 #3
0
ファイル: Language.cs プロジェクト: ioying/Scut
        /// <summary>
        /// Set language object.
        /// </summary>
        private static void SetLang(string typeName)
        {
            var obj = ScriptEngines.ExecuteCSharp(typeName);

            if (obj != null)
            {
                _instance = obj;
            }
            else
            {
                TraceLog.WriteWarn("Can not find the corresponding language configuration,typeName:{0}", typeName);//By Seamoon
            }
        }