namespace LanVersionSwitch.Common
{
public class LanSwitch
{
private static readonly object obj = new object();
public static string GetValue(string section, string key, string lan)
{
string filePath;
if(HttpContext.Current.Cache[section + "_" + key + "_" + lan] == null)
{
lock (obj)
{
if (HttpContext.Current.Cache[section + "_" + key + "_" + lan] == null)
{
if (lan.ToUpper() == "EN")
{
filePath =Environment.CurrentDirectory + "/" + System.Configuration.ConfigurationManager.AppSettings["filePathEn"].ToString();
}
else
{
filePath = Environment.CurrentDirectory + "/" + System.Configuration.ConfigurationManager.AppSettings["filePathCn"].ToString();
}
ManagerConfigIni mi = new ManagerConfigIni(filePath);
HttpContext.Current.Cache.Add(section + "_" + key + "_" + lan, mi.GetIniKeyValueForStr(section, key), null, DateTime.Now.AddSeconds(5), TimeSpan.Zero, CacheItemPriority.Normal, null);
}
}
}
return HttpContext.Current.Cache[section + "_" + key + "_" + lan].ToString();
}
}
}