================= Multiple Bindings ================= If we know that only one binding for the type was specified in configuration file (see :doc:`../xml-configuration-file/index`) or in modules (see :doc:`../bindings-in-modules/index`), we can resolve the type by specifying the type as a parameter to method **IoC.Configuration.DiContainer.IDiContainer.Resove(Type)**, as shown below: .. sourcecode:: csharp private void ResolvingATypeWithSingleBinding(IoC.Configuration.DiContainer.IDiContainer diContainer) { Type typeInterface2 = Helpers.GetType("DynamicallyLoadedAssembly1.Interfaces.IInterface2"); var service1 = diContainer.Resolve(typeInterface2); var service2 = diContainer.Resolve(typeInterface2); Assert.AreNotSame(service1, service2); } However, multiple bindings might be specified for the same type as well. Below are examples of specifying multiple bindings for the same type in configuration file, and in overridden method in method **IoC.Configuration.DiContainer.ModuleAbstr.AddServiceRegistrations()**. Example of multiple bindings for type in XML configuration file: .. code-block:: xml Example of multiple bindings for type in overridden method in method **IoC.Configuration.DiContainer.ModuleAbstr.AddServiceRegistrations()**: .. sourcecode:: csharp public class TestDiModule : IoC.Configuration.DiContainer.ModuleAbstr { protected override void AddServiceRegistrations() { Bind() .To() .SetResolutionScope(DiResolutionScope.Singleton); Bind() .To() .SetResolutionScope(DiResolutionScope.Singleton); Bind() .To() .SetResolutionScope(DiResolutionScope.Transient); } } To resolve types that are bound to multiple types, resolve type **System.Collections.Generic.IEnumerable**. .. note:: We still can resolve to a single type, rather than to a collection. However, not all implementations support this resolution, when multiple bindings exist. For example, **Autofac** implementation will resolve the type to the last binding, while **Ninject** implementation will throw an exception. .. sourcecode:: csharp private void ResolvingATypeWithMultipleBindings(IoC.Configuration.DiContainer.IDiContainer diContainer) { var resolvedInstances = diContainer.Resolve>() .ToList(); Assert.AreEqual(3, resolvedInstances.Count); var typeOfInterface5 = typeof(IInterface5); Assert.IsInstanceOfType(resolvedInstances[0], typeOfInterface5); Assert.IsInstanceOfType(resolvedInstances[1], typeOfInterface5); Assert.IsInstanceOfType(resolvedInstances[2], typeOfInterface5); }