internal void AppendToCollectionInternal(Type itemType, Type implementationType) { // NOTE: The supplied serviceTypes can be opened, partially-closed, closed, non-generic or even // abstract. this.RegisterCollectionInternal(itemType, new[] { ContainerControlledItem.CreateFromType(implementationType) }, appending: true); }
internal static ContainerControlledItem[] GetClosedGenericImplementationsFor( Type closedGenericServiceType, IEnumerable <ContainerControlledItem> containerControlledItems) { return(( from item in containerControlledItems let openGenericImplementation = item.ImplementationType let builder = new GenericTypeBuilder(closedGenericServiceType, openGenericImplementation) let result = builder.BuildClosedGenericImplementation() where result.ClosedServiceTypeSatisfiesAllTypeConstraints select item.Registration != null ? item : ContainerControlledItem.CreateFromType(result.ClosedGenericImplementation)) .ToArray()); }
internal static ContainerControlledItem[] GetClosedGenericImplementationsFor( Type closedGenericServiceType, IEnumerable <ContainerControlledItem> containerControlledItems, bool includeVariantTypes = true) { return(( from item in containerControlledItems let openGenericImplementation = item.ImplementationType let builder = new GenericTypeBuilder(closedGenericServiceType, openGenericImplementation) let result = builder.BuildClosedGenericImplementation() where result.ClosedServiceTypeSatisfiesAllTypeConstraints || ( includeVariantTypes && closedGenericServiceType.IsAssignableFrom(openGenericImplementation)) let closedImplementation = result.ClosedServiceTypeSatisfiesAllTypeConstraints ? result.ClosedGenericImplementation : openGenericImplementation select item.Registration != null ? item : ContainerControlledItem.CreateFromType(closedImplementation)) .ToArray()); }