/// <summary>   
        /// Gets the principal builder factory instance implementing <see cref="T: EPS.Web.Abstractions.IPrincipalBuilderFactory"/>, and uses
        /// that to create instances of <see cref="T: EPS.Web.Abstractions.IPrincipalBuilder"/> given the specified configuration. 
        /// </summary>
        /// <remarks>   ebrown, 1/3/2011. </remarks>
        /// <exception cref="ArgumentNullException">    Thrown when one or more required arguments are null. </exception>
        /// <param name="configuration">    The configuration. </param>
        /// <returns>   The principal builder instance or null if the PrincipalBuilderFactory property is not properly configured. </returns>
        public static IPrincipalBuilder Resolve(AuthenticatorConfigurationElement configuration)
        {
            if (null == configuration) { throw new ArgumentNullException("configuration"); }

            if (string.IsNullOrWhiteSpace(configuration.PrincipalBuilderFactory))
            {
                return null;
            }

            var factory = factories.GetOrAdd(configuration.PrincipalBuilderFactory, factoryName =>
                {
                    return Activator.CreateInstance(Type.GetType(factoryName)) as IPrincipalBuilderFactory;
                });

            return factory.Construct(configuration);
        }
        public static IAuthenticator Construct(AuthenticatorConfigurationElement configuration)
        {
            if (null == configuration) { throw new ArgumentNullException("configuration"); }

            //TODO: 5-21-2010 -- theres a bug here -- dynamic runtime can't find the appropriate Construct method for some reason
            //it *should* work, but doesn't
            //HACK: rather than deal with some funky reflection code, we just use dynamic, since we know there is a Construct here
            //dynamic factoryInstance = Activator.CreateInstance(Type.GetType(Factory));

            //http://stackoverflow.com/questions/266115/pass-an-instantiated-system-type-as-a-type-parameter-for-a-generic-class
            //var t = typeof(IHttpContextInspectingAuthenticatorFactory<>).MakeGenericType(this.GetType());

            return factoryInstances.GetOrAdd(configuration,
                (config) =>
                {
                    return (IAuthenticatorFactory)Activator.CreateInstance(Type.GetType(config.Factory));
                }).Construct(configuration);
        }
        /// <summary>
        /// Gets the principal builder factory instance implementing <see cref="T: EPS.Web.Abstractions.IPrincipalBuilderFactory"/>, and uses
        /// that to create instances of <see cref="T: EPS.Web.Abstractions.IPrincipalBuilder"/> given the specified configuration.
        /// </summary>
        /// <remarks>   ebrown, 1/3/2011. </remarks>
        /// <exception cref="ArgumentNullException">    Thrown when one or more required arguments are null. </exception>
        /// <param name="configuration">    The configuration. </param>
        /// <returns>   The principal builder instance or null if the PrincipalBuilderFactory property is not properly configured. </returns>
        public static IPrincipalBuilder Resolve(AuthenticatorConfigurationElement configuration)
        {
            if (null == configuration)
            {
                throw new ArgumentNullException("configuration");
            }

            if (string.IsNullOrWhiteSpace(configuration.PrincipalBuilderFactory))
            {
                return(null);
            }

            var factory = factories.GetOrAdd(configuration.PrincipalBuilderFactory, factoryName =>
            {
                return(Activator.CreateInstance(Type.GetType(factoryName)) as IPrincipalBuilderFactory);
            });

            return(factory.Construct(configuration));
        }
        public static IAuthenticator Construct(AuthenticatorConfigurationElement configuration)
        {
            if (null == configuration)
            {
                throw new ArgumentNullException("configuration");
            }

            //TODO: 5-21-2010 -- theres a bug here -- dynamic runtime can't find the appropriate Construct method for some reason
            //it *should* work, but doesn't
            //HACK: rather than deal with some funky reflection code, we just use dynamic, since we know there is a Construct here
            //dynamic factoryInstance = Activator.CreateInstance(Type.GetType(Factory));

            //http://stackoverflow.com/questions/266115/pass-an-instantiated-system-type-as-a-type-parameter-for-a-generic-class
            //var t = typeof(IHttpContextInspectingAuthenticatorFactory<>).MakeGenericType(this.GetType());

            return(factoryInstances.GetOrAdd(configuration,
                                             (config) =>
            {
                return (IAuthenticatorFactory)Activator.CreateInstance(Type.GetType(config.Factory));
            }).Construct(configuration));
        }
 public void Construct_ThrowsOnInvalidConfigurationTypeName()
 {
     var config = new AuthenticatorConfigurationElement() { Factory = "GobbledyGook" };
     Assert.Throws<ArgumentNullException>(() => HttpContextInspectorsLocator.Construct(config));
 }
 public void Construct_ReturnsCorrectlyTypedInstance()
 {
     var config = new AuthenticatorConfigurationElement() { Factory = typeof(MockAuthConfigFactory).AssemblyQualifiedName };
     Assert.IsType<MockAuthenticator>(HttpContextInspectorsLocator.Construct(config));
 }