コード例 #1
0
            private Type GetImplementationTypeThroughFactory(InjectionConsumerInfo consumer)
            {
                var context = new TypeFactoryContext(this.serviceType, consumer);

                Type implementationType = this.implementationTypeFactory(context);

                if (implementationType == null)
                {
                    throw new InvalidOperationException(StringResources.FactoryReturnedNull(this.serviceType));
                }

                if (implementationType.ContainsGenericParameters())
                {
                    throw new ActivationException(
                              StringResources.TheTypeReturnedFromTheFactoryShouldNotBeOpenGeneric(
                                  this.serviceType, implementationType));
                }

                Requires.FactoryReturnsATypeThatIsAssignableFromServiceType(this.serviceType, implementationType);

                return(implementationType);
            }
コード例 #2
0
            private Type GetImplementationTypeThroughFactory(InjectionConsumerInfo consumer)
            {
                var context = new TypeFactoryContext(this.serviceType, consumer);

                Type implementationType = this.implementationTypeFactory(context);

                if (implementationType == null)
                {
                    throw new InvalidOperationException(StringResources.FactoryReturnedNull(this.serviceType));
                }

                if (implementationType.ContainsGenericParameters())
                {
                    throw new ActivationException(
                        StringResources.TheTypeReturnedFromTheFactoryShouldNotBeOpenGeneric(
                            this.serviceType, implementationType));
                }

                Requires.FactoryReturnsATypeThatIsAssignableFromServiceType(this.serviceType, implementationType);

                return implementationType;
            }