示例#1
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));
        }
        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)));
        }
示例#3
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));
            }
 internal static void AppendAll(this IContainerControlledCollection collection,
                                IEnumerable <Type> types)
 {
     collection.AppendAll(types.Select(ContainerControlledItem.CreateFromType));
 }
 internal static void AppendAll(this IContainerControlledCollection collection,
                                IEnumerable <Registration> registrations)
 {
     collection.AppendAll(registrations.Select(ContainerControlledItem.CreateFromRegistration));
 }
 internal static void AppendAll(this IContainerControlledCollection collection,
                                IEnumerable <Type> serviceTypes)
 {
     collection.AppendAll(serviceTypes.Select(type => new ContainerControlledItem(type)));
 }