diff --git a/.idea/.idea.LightweightIocContainer/.idea/modules.xml b/.idea/.idea.LightweightIocContainer/.idea/modules.xml
index fd7a90d..0d06f78 100644
--- a/.idea/.idea.LightweightIocContainer/.idea/modules.xml
+++ b/.idea/.idea.LightweightIocContainer/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/LightweightIocContainer/Interfaces/IIocContainer.cs b/LightweightIocContainer/Interfaces/IIocContainer.cs
index d4c1465..efdb7ba 100644
--- a/LightweightIocContainer/Interfaces/IIocContainer.cs
+++ b/LightweightIocContainer/Interfaces/IIocContainer.cs
@@ -101,6 +101,16 @@ namespace LightweightIocContainer.Interfaces
/// The created
IMultitonRegistration RegisterMultiton() where TImplementation : TInterface;
+ ///
+ /// Register multiple interfaces for a that implements them as a multiton
+ ///
+ /// The base interface to register
+ /// A second interface to register
+ /// The Type that implements the interface
+ /// The Type of the multiton scope
+ /// The created
+ IMultipleMultitonRegistration RegisterMultiton() where TImplementation : TInterface1, TInterface2;
+
///
/// Register an Interface as an abstract typed factory
///
diff --git a/LightweightIocContainer/Interfaces/Registrations/IMultipleMultitonRegistration.cs b/LightweightIocContainer/Interfaces/Registrations/IMultipleMultitonRegistration.cs
new file mode 100644
index 0000000..079248d
--- /dev/null
+++ b/LightweightIocContainer/Interfaces/Registrations/IMultipleMultitonRegistration.cs
@@ -0,0 +1,17 @@
+// Author: Gockner, Simon
+// Created: 2020-11-19
+// Copyright(c) 2020 SimonG. All Rights Reserved.
+
+namespace LightweightIocContainer.Interfaces.Registrations
+{
+ ///
+ /// An to register multiple interfaces for on implementation type that implements them as a multiton
+ ///
+ /// The first interface
+ /// The second interface
+ /// The implementation
+ public interface IMultipleMultitonRegistration : IMultitonRegistration, IMultipleRegistration where TImplementation : TInterface1, TInterface2
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs b/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
index 2106215..5b20f0e 100644
--- a/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
@@ -17,7 +17,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
///
/// A base without implementation
///
- public interface IMultitonRegistration : IRegistrationBase, IMultitonRegistration
+ public interface IMultitonRegistration : ITypedRegistrationBase, IMultitonRegistration
{
///
/// The of the multiton scope
diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs
index c95a555..0382121 100644
--- a/LightweightIocContainer/IocContainer.cs
+++ b/LightweightIocContainer/IocContainer.cs
@@ -193,6 +193,22 @@ namespace LightweightIocContainer
return registration;
}
+ ///
+ /// Register multiple interfaces for a that implements them as a multiton
+ ///
+ /// The base interface to register
+ /// A second interface to register
+ /// The Type that implements the interface
+ /// The Type of the multiton scope
+ /// The created
+ public IMultipleMultitonRegistration RegisterMultiton() where TImplementation : TInterface1, TInterface2
+ {
+ IMultipleMultitonRegistration registration = _registrationFactory.RegisterMultiton();
+ Register(registration);
+
+ return registration;
+ }
+
///
/// Register an Interface as an abstract typed factory
///
@@ -377,7 +393,7 @@ namespace LightweightIocContainer
throw new MultitonResolveException($"Can not resolve multiton without the first argument being the scope (should be of type {registration.Scope}).", typeof(T));
//if a multiton for the given scope exists return it
- var instances = _multitons.FirstOrDefault(m => m.type == typeof(T) && m.scope == registration.Scope).instances; //get instances for the given type and scope
+ var instances = _multitons.FirstOrDefault(m => m.type == registration.ImplementationType && m.scope == registration.Scope).instances; //get instances for the given type and scope (use implementation type to resolve the correct instance for multiple multiton registrations as well)
if (instances != null)
{
if (instances.TryGetValue(scopeArgument, out object instance))
@@ -394,7 +410,7 @@ namespace LightweightIocContainer
ConditionalWeakTable