Exemple #1
0
        /// <summary>
        /// Builds an instance of an IRevocationLookup client based on configuration.
        /// </summary>
        /// <returns>ocsp lookup</returns>
        private IRevocationLookup CreateInstance()
        {
            // 1. Get factory config:
            RevocationLookupFactoryConfig config = ConfigurationHandler.GetConfigurationSection <RevocationLookupFactoryConfig>();

            return(this.CreateInstance(config));
        }
Exemple #2
0
        /// <summary>
        /// Builds an instance of an IRevocationLookup client based on configuration.
        /// </summary>
        /// <returns>ocsp lookup</returns>
        private IRevocationLookup CreateInstance(RevocationLookupFactoryConfig config)
        {
            // 1. Get the type to load:
            if (config.ImplementationNamespaceClass == null || config.ImplementationNamespaceClass == "")
            {
                throw new RevocationNoImplementingClassException();
            }
            if (config.ImplementationAssembly == null || config.ImplementationAssembly == "")
            {
                throw new RevocationNoImplementingAssemblyException();
            }
            string qualifiedTypename = config.ImplementationNamespaceClass + ", " + config.ImplementationAssembly;
            Type   lookupClientType  = Type.GetType(qualifiedTypename);

            if (lookupClientType == null)
            {
                throw new FailedToLoadLookupTypeException(qualifiedTypename);
            }

            // 3. Instantiate the type:
            IRevocationLookup lookupClient = (IRevocationLookup)lookupClientType.GetConstructor(new Type[0]).Invoke(null);

            return(lookupClient);
        }