/// <summary> /// Loads provider /// </summary> static YahooAuthenticationProvider LoadProvider() { // Get the names of the providers // Use the cache because the reflection used later is expensive Cache cache = HttpRuntime.Cache; string cacheKey; YahooAuthenticationProvider _instanceLoader; YahooAuthenticationProviderConfiguration config = YahooAuthenticationProviderConfiguration.GetConfig(); cacheKey = "YahooAuthenticationProvider::" + config.DefaultProvider; object oProvider = cache.Get(cacheKey); if (oProvider != null) { _instanceLoader = (YahooAuthenticationProvider)oProvider; } else { try { // Read the configuration specific information for this provider ProviderAttributes providerAttributes = (ProviderAttributes)config.Providers[config.DefaultProvider]; // The assembly should be in \bin or GAC Type type = Type.GetType(providerAttributes.Type); _instanceLoader = (YahooAuthenticationProvider)Activator.CreateInstance(type); // Initialize the provider with the attributes. string cStringName = providerAttributes.Attributes["connectionStringName"]; if (!String.IsNullOrEmpty(cStringName) && ConfigurationManager.ConnectionStrings != null && ConfigurationManager.ConnectionStrings[cStringName] != null) { string cString = ConfigurationManager.ConnectionStrings[cStringName].ConnectionString; providerAttributes.Attributes.Add("connectionString", cString); } _instanceLoader.Initialize(providerAttributes.Name, providerAttributes.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) { YahooAuthenticationProviderConfiguration config = new YahooAuthenticationProviderConfiguration(); config.LoadValuesFromConfigurationXml(node); return config; }