| | |
| | |
|
| | | public class ConfigBase<U, T> where T : ConfigBase<U, T>, new()
|
| | | {
|
| | | static ConfigBase()
|
| | | {
|
| | | if (isInit)
|
| | | {
|
| | | return;
|
| | | }
|
| | | LazyInit();
|
| | | }
|
| | |
|
| | | private static Dictionary<U, T> m_dic = new Dictionary<U, T>();
|
| | |
|
| | | public static Dictionary<U, T> dic
|
| | | {
|
| | | get
|
| | | {
|
| | | LazyInit();
|
| | | return m_dic;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public static T Get(U id)
|
| | | {
|
| | | LazyInit();
|
| | |
|
| | | if (m_dic.ContainsKey(id))
|
| | | {
|
| | | return m_dic[id];
|
| | |
| | | isInit = false;
|
| | | }
|
| | |
|
| | | public static void ForceInit()
|
| | | {
|
| | | ConfigManager.Instance.LoadConfigByType(typeof(T));
|
| | | }
|
| | |
|
| | | public static List<U> GetKeys()
|
| | | {
|
| | | LazyInit();
|
| | | List<U> result = new List<U>();
|
| | | result.AddRange(m_dic.Keys);
|
| | | return result;
|
| | |
| | |
|
| | | public static List<T> GetValues()
|
| | | {
|
| | | LazyInit();
|
| | | List<T> result = new List<T>();
|
| | | result.AddRange(m_dic.Values);
|
| | | return result;
|
| | |
| | |
|
| | | public static bool HasKey(U key)
|
| | | {
|
| | | LazyInit();
|
| | |
|
| | | return m_dic.ContainsKey(key);
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | if (isInit)
|
| | | {
|
| | | Debug.LogError("重复加载表格 类型 " + typeof(T).Name);
|
| | | return;
|
| | | }
|
| | |
|