Esempio n. 1
0
        public static void Load(this ConfigComponent self)
        {
            AppType appType = StartConfigComponent.Instance.StartConfig.AppType;

            self.AllConfig.Clear();
            List <Type> types = Game.EventSystem.GetTypes(typeof(ConfigAttribute));

            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(ConfigAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }

                ConfigAttribute configAttribute = attrs[0] as ConfigAttribute;
                // 只加载指定的配置
                if (!configAttribute.Type.Is(appType))
                {
                    continue;
                }

                object obj = Activator.CreateInstance(type);

                ACategory iCategory = obj as ACategory;
                if (iCategory == null)
                {
                    throw new Exception($"class: {type.Name} not inherit from ACategory");
                }
                iCategory.BeginInit();
                iCategory.EndInit();

                self.AllConfig[iCategory.ConfigType] = iCategory;
            }
        }
Esempio n. 2
0
        public void Load()
        {
            this.allConfig.Clear();
            Type[] types = ETModel.Game.Hotfix.GetHotfixTypes();

            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(ConfigAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }
                object obj = Activator.CreateInstance(type);

                ACategory iCategory = obj as ACategory;
                if (iCategory == null)
                {
                    throw new Exception($"class: {type.Name} not inherit from ACategory");
                }
                iCategory.BeginInit();
                iCategory.EndInit();

                this.allConfig[iCategory.ConfigType] = iCategory;
            }
        }
Esempio n. 3
0
        public static void ReloadOnly(this ConfigComponent self, Type type)
        {
            object obj = Activator.CreateInstance(type);

            ACategory iCategory = obj as ACategory;

            if (iCategory == null)
            {
                throw new Exception($"class: {type.Name} not inherit from ACategory");
            }
            iCategory.BeginInit();
            iCategory.EndInit();

            self.AllConfig[iCategory.ConfigType] = iCategory;
        }
Esempio n. 4
0
        public static void Load(this ConfigComponent self)
        {
            self.AllConfig.Clear();
            HashSet <Type> types = Game.EventSystem.GetTypes(typeof(ConfigAttribute));

            foreach (Type type in types)
            {
                object obj = Activator.CreateInstance(type);

                ACategory iCategory = obj as ACategory;
                if (iCategory == null)
                {
                    throw new Exception($"class: {type.Name} not inherit from ACategory");
                }
                iCategory.BeginInit();
                iCategory.EndInit();

                self.AllConfig[iCategory.ConfigType] = iCategory;
            }
        }