Esempio n. 1
0
 private static System.Configuration.Configuration GetConfigurationCode(string configCode)
 {
     if (string.IsNullOrWhiteSpace(configCode))
     {
         return(null);
     }
     System.Configuration.Configuration fromCache = CacheHelper.GetFromCache <System.Configuration.Configuration>(WTF.Framework.CacheType.Framework.ToString(), configCode);
     if (fromCache == null)
     {
         if (CacheHelper.GetFromCache(WTF.Framework.CacheType.Framework.ToString(), configCode + "NoFile") != null)
         {
             return(null);
         }
         ReaderWriterLockSlim slim = objConfigWriterLockSlimHelper.CreateLock(configCode);
         slim.EnterWriteLock();
         try
         {
             fromCache = CacheHelper.GetFromCache <System.Configuration.Configuration>(WTF.Framework.CacheType.Framework.ToString(), configCode);
             if (fromCache == null)
             {
                 if (CacheHelper.GetFromCache(WTF.Framework.CacheType.Framework.ToString(), configCode + "NoFile") != null)
                 {
                     return(null);
                 }
                 string configPath = GetConfigPath(configCode);
                 if (!File.Exists(configPath))
                 {
                     true.AddToFileCache(WTF.Framework.CacheType.Framework.ToString(), configCode + "NoFile", configPath);
                     return(null);
                 }
                 ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap {
                     ExeConfigFilename = configPath
                 };
                 fromCache = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
                 fromCache.AddToFileCache(WTF.Framework.CacheType.Framework.ToString(), configCode, configPath);
             }
             return(fromCache);
         }
         finally
         {
             slim.ExitWriteLock();
         }
     }
     return(fromCache);
 }