public static DatePickerConfiguration GetConfig() { DatePickerConfiguration datePickerConfig = null; if ( (HttpRuntime.Cache["mojoDatePickerConfig"] != null) && (HttpRuntime.Cache["mojoDatePickerConfig"] is DatePickerConfiguration) ) { return (DatePickerConfiguration)HttpRuntime.Cache["mojoDatePickerConfig"]; } else { String configFileName = "mojoDatePicker.config"; if (ConfigurationManager.AppSettings["mojoDatePickerConfigFileName"] != null) { configFileName = ConfigurationManager.AppSettings["mojoDatePickerConfigFileName"]; } if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } String pathToConfigFile = HttpContext.Current.Server.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); datePickerConfig = new DatePickerConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); System.Web.HttpRuntime.Cache.Insert( "mojoDatePickerConfig", datePickerConfig, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return (DatePickerConfiguration)HttpRuntime.Cache["mojoDatePickerConfig"]; } }
public static DatePickerConfiguration GetConfig() { DatePickerConfiguration datePickerConfig = null; if ( (HttpRuntime.Cache["mojoDatePickerConfig"] != null) && (HttpRuntime.Cache["mojoDatePickerConfig"] is DatePickerConfiguration) ) { return((DatePickerConfiguration)HttpRuntime.Cache["mojoDatePickerConfig"]); } else { String configFileName = "mojoDatePicker.config"; if (ConfigurationManager.AppSettings["mojoDatePickerConfigFileName"] != null) { configFileName = ConfigurationManager.AppSettings["mojoDatePickerConfigFileName"]; } if (!configFileName.StartsWith("~/")) { configFileName = "~/" + configFileName; } String pathToConfigFile = HttpContext.Current.Server.MapPath(configFileName); XmlDocument configXml = new XmlDocument(); configXml.Load(pathToConfigFile); datePickerConfig = new DatePickerConfiguration(configXml.DocumentElement); AggregateCacheDependency aggregateCacheDependency = new AggregateCacheDependency(); aggregateCacheDependency.Add(new CacheDependency(pathToConfigFile)); System.Web.HttpRuntime.Cache.Insert( "mojoDatePickerConfig", datePickerConfig, aggregateCacheDependency, DateTime.Now.AddYears(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); return((DatePickerConfiguration)HttpRuntime.Cache["mojoDatePickerConfig"]); } }
private static void Initialize() { //try //{ DatePickerConfiguration config = DatePickerConfiguration.GetConfig(); if ( (config.DefaultProvider == null) || (config.Providers == null) || (config.Providers.Count < 1) ) { throw new ProviderException("You must specify a valid default provider."); } providerCollection = new DatePickerProviderCollection(); ProvidersHelper.InstantiateProviders( config.Providers, providerCollection, typeof(DatePickerProvider)); providerCollection.SetReadOnly(); defaultProvider = providerCollection[config.DefaultProvider]; //} //catch (Exception ex) //{ // initializationException = ex; // //isInitialized = true; // throw ex; //} //isInitialized = true; }