using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using Muchinfo.PC.Common.Bosn; namespace Muchinfo.MTPClient.Resources { public class DeliveryResxManager { private const string _fileName = "DeliveryResx.dll"; public static CommonResx DeliveryResx { get; set; } /// /// 保存错误资源文件 /// /// /// public static void SaveDeliveryResx(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 GetDeliveryResx() { 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 DeliveryDesc(string constKey) { if (DeliveryResx != null && DeliveryResx.ResourceHashtable != null && DeliveryResx.ResourceHashtable.ContainsKey(constKey)) { return DeliveryResx.ResourceHashtable[constKey] as string; } else { return Client_Resource.ResourceManager.GetString(constKey); } } /// /// 初始化错误资源 /// public static void InitDeliveryResx() { DeliveryResx = GetDeliveryResx(); } /// /// 保存并设置资源内容 /// /// /// public static void ConstResxSaveRep(Hashtable resxHashtable, ulong ver) { DeliveryResx = new CommonResx() { ResourceHashtable = resxHashtable, Version = ver }; SaveDeliveryResx(resxHashtable, ver); } #region 数据存在UserData目录 public static void InitDeliveryResx(string filePath) { DeliveryResx = GetDeliveryResx(filePath); } public static void SaveDeliveryResx(Hashtable hastableResx, ulong ver, string filePath) { string path = Path.Combine(filePath, _fileName); ResxManagerHelper.SaveData(hastableResx, ver, path); } private static CommonResx GetDeliveryResx(string filePath) { string path = Path.Combine(filePath, _fileName); return ResxManagerHelper.GetData(path); } #endregion } }