| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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; }
- /// <summary>
- /// 保存错误资源文件
- /// </summary>
- /// <param name="hastableResx"></param>
- /// <param name="ver"></param>
- 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<CommonResx>(path, resx, null, true);
- }
- /// <summary>
- /// 获取 资源信息
- /// </summary>
- /// <returns></returns>
- 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<CommonResx>(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);
- }
- }
- /// <summary>
- /// 初始化错误资源
- /// </summary>
- public static void InitDeliveryResx()
- {
- DeliveryResx = GetDeliveryResx();
- }
- /// <summary>
- /// 保存并设置资源内容
- /// </summary>
- /// <param name="resxHashtable"></param>
- /// <param name="ver"></param>
- 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
- }
- }
|