/// <summary> /// Creates photo provider configuration /// </summary> /// <param name="parent"></param> /// <param name="context"></param> /// <param name="node"></param> /// <returns></returns> public virtual object Create(Object parent, Object context, XmlNode node) { UrlMappingProviderConfiguration config = new UrlMappingProviderConfiguration(); config.LoadValuesFromConfigurationXml(node); return(config); }
/// <summary> /// Loads provider /// </summary> static UrlMappingProvider LoadProvider() { // Get the names of the providers // Use the cache because the reflection used later is expensive Cache cache = HttpRuntime.Cache; string cacheKey; UrlMappingProvider _instanceLoader; UrlMappingProviderConfiguration config = UrlMappingProviderConfiguration.GetConfig(); cacheKey = "UrlMappingProvider::" + config.DefaultProvider; object oProvider = cache.Get(cacheKey); if (oProvider != null) { _instanceLoader = (UrlMappingProvider)oProvider; } else { try { // Read the configuration specific information for this provider Provider provider = (Provider)config.Providers[config.DefaultProvider]; // The assembly should be in \bin or GAC Type type = Type.GetType(provider.Type); _instanceLoader = (UrlMappingProvider)Activator.CreateInstance(type); // Initialize the provider with the attributes. string cStringName = provider.Attributes["connectionStringName"]; if (!String.IsNullOrEmpty(cStringName) && ConfigurationManager.ConnectionStrings != null && ConfigurationManager.ConnectionStrings[cStringName] != null) { string cString = ConfigurationManager.ConnectionStrings[cStringName].ConnectionString; provider.Attributes.Add("connectionString", cString); } _instanceLoader.Initialize(provider.Name, provider.Attributes); //pop it into the cache to keep out site from running into the ground :) cache.Insert(cacheKey, _instanceLoader); } catch (Exception e) { throw new Exception("Unable to load provider", e); } } return(_instanceLoader); }
/// <summary> /// Creates photo provider configuration /// </summary> /// <param name="parent"></param> /// <param name="context"></param> /// <param name="node"></param> /// <returns></returns> public virtual object Create(Object parent, Object context, XmlNode node) { UrlMappingProviderConfiguration config = new UrlMappingProviderConfiguration(); config.LoadValuesFromConfigurationXml(node); return config; }