예제 #1
0
        /// <summary>
        /// Creates an IUddiLookup implementation, as set in config.
        /// </summary>
        /// <returns>The IUddiLookup implementation</returns>
        public IUddiLookupClient CreateUddiLookupClient(Uri address)
        {
            // 1. Get factory config:
            _config = ConfigurationHandler.GetConfigurationSection <UddiLookupClientFactoryConfig>();

            // 2. Get the type to load:
            if (string.IsNullOrEmpty(_config.ImplementationNamespaceClass))
            {
                throw new UddiNoImplementingClassException();
            }

            if (string.IsNullOrEmpty(_config.ImplementationAssembly))
            {
                throw new UddiNoImplementingAssemblyException();
            }

            string qualifiedTypename = _config.ImplementationNamespaceClass + ", " + _config.ImplementationAssembly;

            Type lookupClientType = Type.GetType(qualifiedTypename);

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

            // 3. Instantiate the type:
            object[]          parameters      = new object[] { address };
            Type[]            typeArray       = new Type[] { typeof(Uri) };
            ConstructorInfo   constructorInfo = lookupClientType.GetConstructor(typeArray);
            IUddiLookupClient lookupClient    = (IUddiLookupClient)constructorInfo.Invoke(parameters);

            return(lookupClient);
        }