//using System; //using System.Collections.Generic; //namespace ET //{ // public class DataTableComponentAwakeSystem : AwakeSystem // { // public override void Awake(DataTableComponent self) // { // self.Awake(); // } // } // public class DataTableComponent : Entity // { // private readonly Dictionary allConfig = new Dictionary(); // public static DataTableComponent instance { get; set; } // public void Awake() // { // instance = this; // Load(); // } // public void Load() // { // this.allConfig.Clear(); // List types = Game.EventSystem.GetTypes(); // foreach (Type type in types) // { // object[] attrs = type.GetCustomAttributes(typeof(ConfigAttribute), false); // if (attrs.Length == 0) // { // continue; // } // ConfigAttribute configAttribute = attrs[0] as ConfigAttribute; // 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 IConfig GetOne(Type type) // { // ACategory configCategory; // if (!this.allConfig.TryGetValue(type, out configCategory)) // { // throw new Exception($"ConfigComponent not found key: {type.FullName}"); // } // return configCategory.GetOne(); // } // public IConfig Get(Type type, long id) // { // ACategory configCategory; // if (!this.allConfig.TryGetValue(type, out configCategory)) // { // throw new Exception($"ConfigComponent not found key: {type.FullName}"); // } // return configCategory.TryGet(id); // } // public IEnumerable GetAll(Type type) // { // ACategory configCategory; // if (!this.allConfig.TryGetValue(type, out configCategory)) // { // throw new Exception($"ConfigComponent not found key: {type.FullName}"); // } // return configCategory.GetAll(); // } // public ACategory GetCategory(Type type) // { // ACategory configCategory; // bool ret = this.allConfig.TryGetValue(type, out configCategory); // return ret ? configCategory : null; // } // internal void Destroy() // { // allConfig.Clear(); // instance = null; // } // } //}