Пример #1
0
        public static T ReadXmlFileWithLocalCache <T>(string filePath)
            where T : class
        {
            if (!File.Exists(filePath))
            {
                return(null);
            }
            FileInfo f   = new FileInfo(filePath);
            string   key = "ReadXmlFileWithCache_" + f.FullName.ToUpper().GetHashCode().ToString();

            return(GetWithLocalCache <T>(key, () => SerializationUtility.LoadFromXml <T>(filePath), filePath));
        }
Пример #2
0
        internal static void LoadResouce(string cacheKey, string filePath)
        {
            cacheKey = cacheKey.ToUpper();
            MessageResource res = SerializationUtility.LoadFromXml <MessageResource>(filePath);

            lock (s_SyncObj)
            {
                if (s_MessageResDictionary.ContainsKey(cacheKey))
                {
                    s_MessageResDictionary[cacheKey] = res;
                }
                else
                {
                    s_MessageResDictionary.Add(cacheKey, res);
                }
            }
        }