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 MenuResxManager { private const string _fileName = "MenuResx.dll"; public static CommonResx MenuResx { get; set; } public static void SaveMenuResx(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 GetMenuResx() { 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 MenuDesc(string constKey) { if (MenuResx != null && MenuResx.ResourceHashtable != null && MenuResx.ResourceHashtable.ContainsKey(constKey)) { return MenuResx.ResourceHashtable[constKey] as string; } else { return Client_Resource.ResourceManager.GetString(constKey); } } public static void InitMenuResx() { MenuResx = GetMenuResx(); } #region 数据存在UserData目录 public static void InitMenuResx(string filePath) { MenuResx = GetMenuResx(filePath); } public static void SaveMenuResx(Hashtable hastableResx, ulong ver, string filePath) { string path = Path.Combine(filePath, _fileName); ResxManagerHelper.SaveData(hastableResx, ver, path); } private static CommonResx GetMenuResx(string filePath) { string path = Path.Combine(filePath, _fileName); return ResxManagerHelper.GetData(path); } #endregion } }