// Note that if multiple contract types are provided per concrete type, // it will re-use the same provider for each contract type // (each concrete type will have its own provider though) protected void RegisterProvidersForAllContractsPerConcreteType( DiContainer container, List <Type> concreteTypes, Func <DiContainer, Type, IProvider> providerFunc) { Assert.That(!BindInfo.ContractTypes.IsEmpty()); Assert.That(!concreteTypes.IsEmpty()); var providerMap = ZenPools.SpawnDictionary <Type, IProvider>(); try { foreach (var concreteType in concreteTypes) { var provider = providerFunc(container, concreteType); providerMap[concreteType] = provider; if (BindInfo.MarkAsUniqueSingleton) { container.SingletonMarkRegistry.MarkSingleton(concreteType); } else if (BindInfo.MarkAsCreationBinding) { container.SingletonMarkRegistry.MarkNonSingleton(concreteType); } } foreach (var contractType in BindInfo.ContractTypes) { foreach (var concreteType in concreteTypes) { if (ValidateBindTypes(concreteType, contractType)) { RegisterProvider(container, contractType, providerMap[concreteType]); } } } } finally { ZenPools.DespawnDictionary(providerMap); } }