using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Collections; using Muchinfo.PC.Common.Bosn; namespace Muchinfo.MTPClient.Resources { public class GoodsResxManager { private const string _fileName = "GoodsResx.dll"; public static CommonResx GoodsResx { get; set; } public static void SaveGoodsResx(Hashtable hastableResx, ulong ver) { var resx = new CommonResx() { ResourceHashtable = hastableResx, Version = ver }; string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName); JsonHelper.SaveData(path, resx, null, true); } public static CommonResx GetGoodsResx() { var resx = new CommonResx() { Version = 0 }; string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName); if (!File.Exists(path)) return resx; return JsonHelper.LoadData(path).FirstOrDefault(); } public static string GoodsDesc(string constKey) { if (GoodsResx != null && GoodsResx.ResourceHashtable != null && GoodsResx.ResourceHashtable.ContainsKey(constKey)) { return GoodsResx.ResourceHashtable[constKey] as string; } else { return Client_Resource.ResourceManager.GetString(constKey); } } public static void InitGoodsResx() { GoodsResx = GetGoodsResx(); } #region 数据存在UserData目录 public static void InitGoodsResx(string filePath) { GoodsResx = GetGoodsResx(filePath); } public static void SaveGoodsResx(Hashtable hastableResx, ulong ver, string filePath) { string path = Path.Combine(filePath, _fileName); ResxManagerHelper.SaveData(hastableResx, ver, path); } private static CommonResx GetGoodsResx(string filePath) { string path = Path.Combine(filePath, _fileName); return ResxManagerHelper.GetData(path); } #endregion } }