hch
9 天以前 cb653cf75b17b9bdca0b5b9e6b88edf1ca72e90c
Main/Config/ConfigBase.cs
@@ -7,13 +7,27 @@
public class ConfigBase<U, T> where T : ConfigBase<U, T>, new()
{
    /// <summary>
    /// 是否访问过静态构造函数
    /// </summary>
    public static bool visit = false;
    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;
        }
    }
@@ -22,8 +36,6 @@
    public static T Get(U id)
    {
        LazyInit();
        if (m_dic.ContainsKey(id))
        {
            return m_dic[id];
@@ -32,20 +44,14 @@
        return null;
    }
    public static void ForceRelease()
    {
        m_dic.Clear();
        isInit = false;
    }
    public static void ForceInit()
    {
        ConfigManager.Instance.LoadConfigByType(typeof(T));
    }
    // public static void ForceRelease()
    // {
    //     m_dic.Clear();
    //     isInit = false;
    // }
    public static List<U> GetKeys()
    {
        LazyInit();
        List<U> result = new List<U>();
        result.AddRange(m_dic.Keys);
        return result;
@@ -54,7 +60,6 @@
    public static List<T> GetValues()
    {
        LazyInit();
        List<T> result = new List<T>();
        result.AddRange(m_dic.Values);
        return result;
@@ -62,8 +67,6 @@
    public static bool HasKey(U key)
    {
        LazyInit();
        return m_dic.ContainsKey(key);
    }
@@ -80,7 +83,6 @@
    {
        if (isInit)
        {
            Debug.LogError("重复加载表格  类型 " + typeof(T).Name);
            return;
        }