| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/12/17 22:21:24
- //Author
- //Description Create
- //----------------------------------------------------------------
- using Muchinfo.PC.Common.Bosn;
- namespace Muchinfo.MTPClient.Resources
- {
- public class ConstResxManager
- {
- private const string _fileName = "ContResx.dll";
- public static CommonResx ConstResx { get; set; }
- /// <summary>
- /// 保存错误资源文件
- /// </summary>
- /// <param name="hastableResx"></param>
- /// <param name="ver"></param>
- public static void SaveCostResx(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 GetConstResx()
- {
- 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 ConstDesc(string constKey)
- {
- if (ConstResx != null && ConstResx.ResourceHashtable != null &&
- ConstResx.ResourceHashtable.ContainsKey(constKey))
- {
- return ConstResx.ResourceHashtable[constKey] as string;
- }
- else
- {
- return Client_Resource.ResourceManager.GetString(constKey);
- }
- }
- /// <summary>
- /// 初始化错误资源
- /// </summary>
- public static void InitConstResx()
- {
- ConstResx = GetConstResx();
- }
- /// <summary>
- /// 保存并设置资源内容
- /// </summary>
- /// <param name="resxHashtable"></param>
- /// <param name="ver"></param>
- public static void ConstResxSaveRep(Hashtable resxHashtable, ulong ver)
- {
- ConstResx = new CommonResx() {ResourceHashtable = resxHashtable, Version = ver};
- SaveCostResx(resxHashtable, ver);
- }
- #region 数据存在UserData目录
- public static void InitConstResx(string filePath)
- {
- ConstResx = GetConstResx(filePath);
- }
- public static void ConstResxSaveRep(Hashtable resxHashtable, ulong ver, string filePath)
- {
- ConstResx = new CommonResx() { ResourceHashtable = resxHashtable, Version = ver };
- SaveCostResx(resxHashtable, ver, filePath);
- }
- private static void SaveCostResx(Hashtable hastableResx, ulong ver, string filePath)
- {
- string path = Path.Combine(filePath, _fileName);
- ResxManagerHelper.SaveData(hastableResx, ver, path);
- }
- private static CommonResx GetConstResx(string filePath)
- {
- string path = Path.Combine(filePath, _fileName);
- return ResxManagerHelper.GetData(path);
- }
- #endregion
- }
- }
|