private InstanceProducer BuildEmptyCollectionInstanceProducerForEnumerable(Type enumerableType)
        {
            Type elementType = enumerableType.GetGenericArguments()[0];

            var collection = DecoratorHelpers.CreateContainerControlledCollection(elementType, this);

            var registration = new ExpressionRegistration(Expression.Constant(collection, enumerableType), this);

            return(new InstanceProducer(enumerableType, registration));
        }
Пример #2
0
        private Registration BuildContainerControlledRegistration(Type closedServiceType,
                                                                  ContainerControlledItem[] closedGenericImplementations)
        {
            IContainerControlledCollection collection = DecoratorHelpers.CreateContainerControlledCollection(
                closedServiceType, this.Container);

            collection.AppendAll(closedGenericImplementations);

            return(DecoratorHelpers.CreateRegistrationForContainerControlledCollection(closedServiceType,
                                                                                       collection, this.Container));
        }
Пример #3
0
        private InstanceProducer BuildEmptyCollectionInstanceProducerForEnumerable(Type enumerableType)
        {
            Type elementType = enumerableType.GetGenericArguments()[0];

            var collection = DecoratorHelpers.CreateContainerControlledCollection(elementType, this);

            var registration = new ExpressionRegistration(Expression.Constant(collection, enumerableType), this);

            // Producers for ExpressionRegistration are normally ignored as external producer, but in this
            // case the empty collection producer should pop up in the list of GetCurrentRegistrations().
            return(new InstanceProducer(enumerableType, registration, registerExternalProducer: true));
        }
        protected override InstanceProducer BuildCollectionProducer(Type closedServiceType)
        {
            ContainerControlledItem[] closedGenericImplementations =
                this.GetClosedContainerControlledItemsFor(closedServiceType);

            IContainerControlledCollection collection = DecoratorHelpers.CreateContainerControlledCollection(
                closedServiceType, this.Container);

            collection.AppendAll(closedGenericImplementations);

            return(new InstanceProducer(
                       typeof(IEnumerable <>).MakeGenericType(closedServiceType),
                       DecoratorHelpers.CreateRegistrationForContainerControlledCollection(closedServiceType,
                                                                                           collection, this.Container)));
        }
Пример #5
0
            private Registration BuildContainerControlledRegistration(Type closedServiceType,
                                                                      Type[] closedGenericImplementations)
            {
                var registrations = (
                    from closedGenericImplementation in closedGenericImplementations
                    select this.CreateRegistrationForClosedGenericImplementation(
                        closedServiceType,
                        closedGenericImplementation))
                                    .ToArray();

                IContainerControlledCollection collection =
                    DecoratorHelpers.CreateContainerControlledCollection(closedServiceType, this.Container);

                collection.AppendAll(registrations);

                return(DecoratorHelpers.CreateRegistrationForContainerControlledCollection(closedServiceType,
                                                                                           collection, this.Container));
            }