小格
没有目标的人,是在帮那些有目标的人完成目标。

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();
     }
  }
}

posted on 2011-04-13 14:34  小格  阅读(533)  评论(0编辑  收藏  举报