/*
*
* http://mvcresourceloader.codeplex.com/license
*
* */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Everest.Library.Providers.Caching;
using InteSoft.Web.ExternalResourceLoader;
using System.Configuration;
using Everest.Library.Configuration;
namespace InteSoft.Web.ExternalResourceLoader{
public class ConfigManager
{
volatile static object sectionLockHelper = new object();
public static string ConfigFileName
{
get
{
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "externalResources.config");
}
}
public static LoaderConfigurationSection GetSection()
{
var cacheKey = "externalResources:ConfigurationSection";
if (CacheManager.Get(cacheKey) == null)
{
lock (sectionLockHelper)
{
if (CacheManager.Get(cacheKey) == null)
{
//var filemap = new ExeConfigurationFileMap() { ExeConfigFilename = ConfigFileName };
//Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);
var section = ConfigurationSectionManager.GetSection(typeof(LoaderConfigurationSection), ConfigFileName);
CacheManager.Add(cacheKey, section, CacheItemPriority.None, null, new FileDependency(ConfigFileName));
}
}
}
return (LoaderConfigurationSection)CacheManager.Get(cacheKey);
}
}
}
|