Beispiel #1
0
 public static void ReleaseConfigData(CONFIG_PATH path)
 {
     if (configDataDictionary.ContainsKey(path))
     {
         configDataDictionary.Remove(path);
     }
 }
Beispiel #2
0
        /// <summary>
        /// 讀取表單 並且回傳list格式
        /// </summary>
        /// <typeparam name="TData"></typeparam>
        /// <param name="list">回傳的list</param>
        /// <param name="path">目標表單的名稱 會根據enum的Description 去抓資料</param>
        public static void GetDataList <TData>(this List <TData> list, CONFIG_PATH path) where TData : new()
        {
            List <TData> tempList = new List <TData>();

            list.Clear();

            if (configDataDictionary.ContainsKey(path))
            {
                tempList = configDataDictionary[path] as List <TData>;
            }

            if (tempList == null || !configDataDictionary.ContainsKey(path))
            {
                ReleaseConfigData(path);
                LoadConfigData <TData>(path);
                tempList = configDataDictionary[path] as List <TData>;
            }

            if (tempList != null)
            {
                for (int i = 0; i < tempList.Count; i++)
                {
                    list.Add(tempList[i]);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 把表單用list的方式先讀取進來
        /// </summary>
        /// <typeparam name="TData"></typeparam>
        /// <param name="path">目標表單的名稱 會根據enum的Description 去抓資料</param>
        public static void LoadConfigData <TData>(CONFIG_PATH path) where TData : new()
        {
            if (!configDataDictionary.ContainsKey(path))
            {
                List <TData> tempList = new List <TData>();

                tempList = GetDisposableDataList <TData>(path);
                configDataDictionary.Add(path, tempList);
            }
        }
Beispiel #4
0
        private static List <TData> GetDisposableDataList <TData>(CONFIG_PATH path) where TData : new()
        {
            ConfigTable configTable = config.getCfg(path);

            if (configTable == null)
            {
                // act.debug.PrintSystem.LogError("config is missing : " + path);
                UnityEngine.Debug.LogError("config is missing : " + path);
                return(null);
            }

            List <TData> dataList = ConfigDataParser.ParseTable <TData>(configTable);

            config.releaseCfg(path);

            return(dataList);
        }
Beispiel #5
0
        private static Dictionary <TKey, TData> GetDisposableDataDictionary <TKey, TData>(CONFIG_PATH path)
            where TKey : new()
            where TData : new()
        {
            ConfigTable configTable = config.getCfg(path);

            Dictionary <TKey, TData> dataDictionary = ConfigDataParser.ParseTable <TKey, TData>(configTable);

            config.releaseCfg(path);

            return(dataDictionary);
        }
Beispiel #6
0
        /// <summary>
        /// 讀取表單 並且回傳Dictionary格式
        /// </summary>
        /// <typeparam name="TKey">dictionary key的資料結構</typeparam>
        /// <typeparam name="TData"></typeparam>
        /// <param name="dictionary">回傳的dictionary</param>
        /// <param name="path">目標表單的名稱 會根據enum的Description 去抓資料</param>
        public static void GetDataDictionary <TKey, TData>(this Dictionary <TKey, TData> dictionary, CONFIG_PATH path)
            where TKey : new()
            where TData : new()
        {
            Dictionary <TKey, TData> tempList = new Dictionary <TKey, TData>();

            dictionary.Clear();

            if (configDataDictionary.ContainsKey(path))
            {
                tempList = configDataDictionary[path] as Dictionary <TKey, TData>;
            }

            if (!configDataDictionary.ContainsKey(path) || tempList == null)
            {
                ReleaseConfigData(path);
                tempList = GetDisposableDataDictionary <TKey, TData>(path);
                configDataDictionary.Add(path, tempList);

                //dictionary = configDataDictionary[path] as Dictionary<TKey, TData>;
            }
            if (tempList != null)
            {
                foreach (KeyValuePair <TKey, TData> kvp in tempList)
                {
                    dictionary.Add(kvp.Key, kvp.Value);
                }
            }
        }