public void Load() { this.allConfig.Clear(); Type[] types = Model.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; } }
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; } }