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; }
///
/// 保存错误资源文件
///
///
///
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(path, resx, null, true);
}
///
/// 获取 资源信息
///
///
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(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);
}
}
///
/// 初始化错误资源
///
public static void InitConstResx()
{
ConstResx = GetConstResx();
}
///
/// 保存并设置资源内容
///
///
///
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
}
}