diff --git a/LightweightIocContainer/Interfaces/IIocContainer.cs b/LightweightIocContainer/Interfaces/IIocContainer.cs
index fba5b84..559ba13 100644
--- a/LightweightIocContainer/Interfaces/IIocContainer.cs
+++ b/LightweightIocContainer/Interfaces/IIocContainer.cs
@@ -27,7 +27,7 @@ namespace LightweightIocContainer.Interfaces
/// The Type that implements the interface
/// The for this
/// The created
- IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface;
+ IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface;
///
/// Register multiple interfaces for a that implements them
@@ -37,7 +37,7 @@ namespace LightweightIocContainer.Interfaces
/// The that implements both interfaces
/// The for this
/// The created
- IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1;
+ IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1;
///
/// Register multiple interfaces for a that implements them
@@ -48,7 +48,7 @@ namespace LightweightIocContainer.Interfaces
/// The that implements both interfaces
/// The for this
/// The created
- IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1;
+ IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1;
///
/// Register multiple interfaces for a that implements them
@@ -60,7 +60,7 @@ namespace LightweightIocContainer.Interfaces
/// The that implements both interfaces
/// The for this
/// The created
- IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1;
+ IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1;
///
/// Register multiple interfaces for a that implements them
@@ -73,7 +73,7 @@ namespace LightweightIocContainer.Interfaces
/// The that implements both interfaces
/// The for this
/// The created
- IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1;
+ IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1;
///
/// Register a without an interface
@@ -90,7 +90,7 @@ namespace LightweightIocContainer.Interfaces
/// The Type that implements the interface
/// The Type of the multiton scope
/// The created
- IMultitonRegistration RegisterMultiton() where TImplementation : TInterface;
+ IMultitonRegistration RegisterMultiton() where TImplementation : TInterface;
///
/// Register an Interface as an abstract typed factory
diff --git a/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs b/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs
index d32a4b3..5569c12 100644
--- a/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs
@@ -8,98 +8,29 @@ using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
{
///
- /// Provides an method to an
+ /// Provides an to the generic
///
- /// The registered interface
- public interface IOnCreate
+ public interface IOnCreate
{
///
/// This is invoked when an instance of this type is created.
- /// Can be set in the by calling
- ///
- Action OnCreateAction { get; }
-
- ///
- /// Pass an that will be invoked when an instance of this type is created
- ///
- /// The
- /// The current instance of this
- IRegistrationBase OnCreate(Action action);
- }
-
- ///
- /// Provides an method to an
- ///
- /// The first registered interface
- /// The second registered interface
- public interface IOnCreate
- {
- ///
- /// Pass an for each interface that will be invoked when instances of the types are created
- ///
- /// The first
- /// The second
- /// The current instance of this
- IMultipleRegistration OnCreate(Action action1, Action action2);
- }
-
- ///
- /// Provides an method to an
- ///
- /// The first registered interface
- /// The second registered interface
- /// The third registered interface
- public interface IOnCreate
- {
- ///
- /// Pass an for each interface that will be invoked when instances of the types are created
- ///
- /// The first
- /// The second
- /// The third
- /// The current instance of this
- IMultipleRegistration OnCreate(Action action1, Action action2, Action action3);
- }
-
- ///
- /// Provides an method to an
- ///
- /// The first registered interface
- /// The second registered interface
- /// The third registered interface
- /// The fourth registered interface
- public interface IOnCreate
- {
- ///
- /// Pass an for each interface that will be invoked when instances of the types are created
+ /// Can be set in the by calling
///
- /// The first
- /// The second
- /// The third
- /// The fourth
- /// The current instance of this
- IMultipleRegistration OnCreate(Action action1, Action action2, Action action3, Action action4);
+ Action
/// The first interface
/// The second interface
- public interface IMultipleRegistration : IMultipleRegistration, IOnCreate
+ /// The implementation
+ public interface IMultipleRegistration : IMultipleRegistration where TImplementation : TInterface1, TInterface2
{
}
@@ -35,7 +36,8 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// The first interface
/// The second interface
/// The third interface
- public interface IMultipleRegistration : IMultipleRegistration, IOnCreate
+ /// The implementation
+ public interface IMultipleRegistration : IMultipleRegistration where TImplementation : TInterface1, TInterface2, TInterface3
{
}
@@ -47,7 +49,8 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// The second interface
/// The third interface
/// The fourth interface
- public interface IMultipleRegistration : IMultipleRegistration, IOnCreate
+ /// The implementation
+ public interface IMultipleRegistration : IMultipleRegistration where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4
{
}
@@ -60,7 +63,8 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// The third interface
/// The fourth interface
/// The fifth interface
- public interface IMultipleRegistration : IMultipleRegistration, IOnCreate
+ /// The implementation
+ public interface IMultipleRegistration : IMultipleRegistration where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5
{
}
diff --git a/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs b/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
index 00b8709..ec32045 100644
--- a/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
@@ -7,14 +7,23 @@ using System;
namespace LightweightIocContainer.Interfaces.Registrations
{
///
- /// The registration that is used to register a multiton
+ /// A base without implementation
///
- /// The registered interface
- public interface IMultitonRegistration : IDefaultRegistration
+ public interface IMultitonRegistration : IRegistrationBase
{
///
/// The of the multiton scope
///
Type Scope { get; }
}
+
+ ///
+ /// The registration that is used to register a multiton
+ ///
+ /// The registered interface
+ /// The registered implementation
+ public interface IMultitonRegistration : IMultitonRegistration, IDefaultRegistration where TImplementation : TInterface
+ {
+
+ }
}
\ No newline at end of file
diff --git a/LightweightIocContainer/Interfaces/Registrations/ITypedRegistrationBase.cs b/LightweightIocContainer/Interfaces/Registrations/ITypedRegistrationBase.cs
index 27728d9..9c7e902 100644
--- a/LightweightIocContainer/Interfaces/Registrations/ITypedRegistrationBase.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/ITypedRegistrationBase.cs
@@ -3,11 +3,12 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
+using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
namespace LightweightIocContainer.Interfaces.Registrations
{
///
- /// A that implements a
+ /// A base without implementation
///
public interface ITypedRegistrationBase : IRegistrationBase
{
@@ -16,4 +17,12 @@ namespace LightweightIocContainer.Interfaces.Registrations
///
Type ImplementationType { get; }
}
+
+ ///
+ /// A that implements a
+ ///
+ public interface ITypedRegistrationBase : ITypedRegistrationBase, IOnCreate where TImplementation : TInterface
+ {
+
+ }
}
\ No newline at end of file
diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs
index 4383d68..d8f5630 100644
--- a/LightweightIocContainer/IocContainer.cs
+++ b/LightweightIocContainer/IocContainer.cs
@@ -60,9 +60,9 @@ namespace LightweightIocContainer
/// The Type that implements the interface
/// The for this
/// The created
- public IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface
+ public IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface
{
- IDefaultRegistration registration = _registrationFactory.Register(lifestyle);
+ IDefaultRegistration registration = _registrationFactory.Register(lifestyle);
Register(registration);
return registration;
@@ -76,9 +76,9 @@ namespace LightweightIocContainer
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1
+ public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1
{
- IMultipleRegistration multipleRegistration = _registrationFactory.Register(lifestyle);
+ IMultipleRegistration multipleRegistration = _registrationFactory.Register(lifestyle);
Register(multipleRegistration);
return multipleRegistration;
@@ -93,9 +93,9 @@ namespace LightweightIocContainer
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1
+ public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1
{
- IMultipleRegistration multipleRegistration =
+ IMultipleRegistration multipleRegistration =
_registrationFactory.Register(lifestyle);
Register(multipleRegistration);
@@ -112,9 +112,9 @@ namespace LightweightIocContainer
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
+ public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
{
- IMultipleRegistration multipleRegistration =
+ IMultipleRegistration multipleRegistration =
_registrationFactory.Register(lifestyle);
Register(multipleRegistration);
@@ -132,9 +132,9 @@ namespace LightweightIocContainer
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
+ public IMultipleRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
{
- IMultipleRegistration multipleRegistration =
+ IMultipleRegistration multipleRegistration =
_registrationFactory.Register(lifestyle);
Register(multipleRegistration);
@@ -162,9 +162,9 @@ namespace LightweightIocContainer
/// The Type that implements the interface
/// The Type of the multiton scope
/// The created
- public IMultitonRegistration RegisterMultiton() where TImplementation : TInterface
+ public IMultitonRegistration RegisterMultiton() where TImplementation : TInterface
{
- IMultitonRegistration registration = _registrationFactory.RegisterMultiton();
+ IMultitonRegistration registration = _registrationFactory.RegisterMultiton();
Register(registration);
return registration;
@@ -203,7 +203,7 @@ namespace LightweightIocContainer
///
/// The given
/// The is already registered in this
- private void Register(IRegistration registration)
+ private void Register(IRegistration registration) //FixMe: Don't allow lifestyle.multiton without iMultitonRegistration
{
//if type is already registered
if (_registrations.Any(r => r.InterfaceType == registration.InterfaceType))
@@ -213,11 +213,12 @@ namespace LightweightIocContainer
}
///
- /// Register all from an
+ /// Register all from an
///
/// The of the first registered interface
- /// The
- private void Register(IMultipleRegistration multipleRegistration)
+ /// The of the registered implementation
+ /// The
+ private void Register(IMultipleRegistration multipleRegistration) where TImplementation : TInterface1
{
foreach (var registration in multipleRegistration.Registrations)
{
@@ -411,7 +412,7 @@ namespace LightweightIocContainer
arguments = UpdateArgumentsWithRegistrationParameters(registration, arguments);
T instance;
- if (registration is IDefaultRegistration defaultRegistration)
+ if (registration is ITypedRegistrationBase defaultRegistration)
{
arguments = ResolveConstructorArguments(defaultRegistration.ImplementationType, arguments, resolveStack);
instance = (T) Activator.CreateInstance(defaultRegistration.ImplementationType, arguments);
@@ -432,7 +433,7 @@ namespace LightweightIocContainer
else
throw new UnknownRegistrationException($"There is no registration of type {registration.GetType().Name}.");
- if (registration is IOnCreate onCreateRegistration)
+ if (registration is IOnCreate onCreateRegistration)
onCreateRegistration.OnCreateAction?.Invoke(instance); //TODO: Allow async OnCreateAction?
return instance;
@@ -445,7 +446,7 @@ namespace LightweightIocContainer
/// The of the given
/// The constructor arguments
/// The argument list updated with the
- private object[] UpdateArgumentsWithRegistrationParameters(IRegistrationBase registration, object[] arguments)
+ private object[] UpdateArgumentsWithRegistrationParameters(IWithParameters registration, object[] arguments)
{
if (arguments != null && arguments.Any()) //if more arguments were passed to resolve
{
diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml
index 04f14cb..da50bc8 100644
--- a/LightweightIocContainer/LightweightIocContainer.xml
+++ b/LightweightIocContainer/LightweightIocContainer.xml
@@ -473,96 +473,30 @@
The current
-
+
- Provides an method to an
+ Provides an to the generic
- The registered interface
-
+
This is invoked when an instance of this type is created.
- Can be set in the by calling
+ Can be set in the by calling
-
-
- Pass an that will be invoked when an instance of this type is created
-
- The
- The current instance of this
-
- Provides an method to an
+ Provides an method to an
- The first registered interface
- The second registered interface
-
-
-
- Pass an for each interface that will be invoked when instances of the types are created
-
- The first
- The second
- The current instance of this
-
-
-
- Provides an method to an
-
- The first registered interface
- The second registered interface
- The third registered interface
-
-
-
- Pass an for each interface that will be invoked when instances of the types are created
-
- The first
- The second
- The third
- The current instance of this
-
-
-
- Provides an method to an
-
- The first registered interface
- The second registered interface
- The third registered interface
- The fourth registered interface
-
-
-
- Pass an for each interface that will be invoked when instances of the types are created
-
- The first
- The second
- The third
- The fourth
- The current instance of this
-
-
-
- Provides an method to an
-
- The first registered interface
- The second registered interface
- The third registered interface
- The fourth registered interface
- The fifth registered interface
+ The registered interface
+ The registered implementation
-
+
- Pass an for each interface that will be invoked when instances of the types are created
+ Pass an that will be invoked when an instance of this type is created
- The first
- The second
- The third
- The fourth
- The fifth
- The current instance of this
+ The
+ The current instance of this
@@ -594,39 +528,43 @@
The current instance of this are already set or no parameters given
-
+
- The to register a for the Interface it implements
+ The to register a for the Interface it implements
The of the interface
+ The of the implementation
-
+
- The base interface for every to register multiple interfaces
+ The base interface for every to register multiple interfaces
The first interface
+ The implementation
-
+
- A of s that are registered within this
+ A of s that are registered within this
-
+
An to register multiple interfaces for on implementation type
The first interfaceThe second interface
+ The implementation
-
+
An to register multiple interfaces for on implementation type
The first interfaceThe second interfaceThe third interface
+ The implementation
-
+
An to register multiple interfaces for on implementation type
@@ -634,8 +572,9 @@
The second interfaceThe third interfaceThe fourth interface
+ The implementation
-
+
An to register multiple interfaces for on implementation type
@@ -644,18 +583,25 @@
The third interfaceThe fourth interfaceThe fifth interface
+ The implementation
- The registration that is used to register a multiton
+ A base without implementation
- The registered interface
The of the multiton scope
+
+
+ The registration that is used to register a multiton
+
+ The registered interface
+ The registered implementation
+
The base registration that is used to register an Interface
@@ -713,7 +659,7 @@
- A that implements a
+ A base without implementation
@@ -721,6 +667,11 @@
The that implements the that is registered with this
+
+
+ A that implements a
+
+
A special that allows to set a as a callback that is called on
@@ -848,12 +799,13 @@
The given The is already registered in this
-
+
- Register all from an
+ Register all from an The of the first registered interface
- The
+ The of the registered implementation
+ The
@@ -923,7 +875,7 @@
The current resolve stack
A newly created instance of the given
-
+
Update the given arguments with the of the given
@@ -980,40 +932,29 @@
A new instance gets created if the given scope has no created instance yet. Otherwise the already created instance is used.
-
+
- The to register a for the Interface it implements
+ The to register a for the Interface it implements
The of the interface
+ The of the implementation
-
+
- The to register a for the Interface it implements
+ The to register a for the Interface it implements
The of the interface
The of the implementation
The of the
-
-
- This is invoked when an instance of this type is created.
- Can be set in the by calling
-
-
-
-
- Pass an that will be invoked when an instance of this is created
-
- The
- The current instance of this
-
-
+
- The base class for every to register multiple interfaces
+ The base class for every to register multiple interfaces
The first interface
+ The implementation
-
+
The base class for every to register multiple interfaces
@@ -1021,19 +962,20 @@
The of the implementation
The of this
-
+
A of s that are registered within this
-
+
An to register multiple interfaces for on implementation type
The first interfaceThe second interface
+ The implementation
-
+
An to register multiple interfaces for on implementation type
@@ -1042,23 +984,23 @@
The of the implementation
The of this
-
+
- Pass an for each interface that will be invoked when instances of the types are created
+ Pass an that will be invoked when an instance of this type is created
- The first
- The second
- The current instance of this
+ The
+ The current instance of this
-
+
An to register multiple interfaces for on implementation type
The first interfaceThe second interfaceThe third interface
+ The implementation
-
+
An to register multiple interfaces for on implementation type
@@ -1068,16 +1010,14 @@
The of the implementation
The of this
-
+
- Pass an for each interface that will be invoked when instances of the types are created
+ Pass an that will be invoked when an instance of this type is created
- The first
- The second
- The third
- The current instance of this
+ The
+ The current instance of this
-
+
An to register multiple interfaces for on implementation type
@@ -1085,8 +1025,9 @@
The second interfaceThe third interfaceThe fourth interface
+ The implementation
-
+
An to register multiple interfaces for on implementation type
@@ -1097,17 +1038,14 @@
The of the implementation
The of this
-
+
- Pass an for each interface that will be invoked when instances of the types are created
+ Pass an that will be invoked when an instance of this type is created
- The first
- The second
- The third
- The fourth
- The current instance of this
+ The
+ The current instance of this
-
+
An to register multiple interfaces for on implementation type
@@ -1116,8 +1054,9 @@
The third interfaceThe fourth interfaceThe fifth interface
+ The implementation
-
+
An to register multiple interfaces for on implementation type
@@ -1129,24 +1068,21 @@
The of the implementation
The of this
-
+
- Pass an for each interface that will be invoked when instances of the types are created
+ Pass an that will be invoked when an instance of this type is created
- The first
- The second
- The third
- The fourth
- The fifth
- The current instance of this
+ The
+ The current instance of this
-
+
The registration that is used to register a multiton
The registered interface
+ The registered implementation
-
+
The registration that is used to register a multiton
@@ -1154,7 +1090,7 @@
The of the Implementation
The of the Multiton Scope
-
+
The of the multiton scope
@@ -1218,12 +1154,12 @@
- Register an Interface with a Type that implements it and create a
+ Register an Interface with a Type that implements it and create a The Interface to registerThe Type that implements the interface
- The for this
- A new created with the given parameters
+ The for this
+ A new created with the given parameters
@@ -1281,12 +1217,12 @@
- Register an Interface with a Type that implements it as a multiton and create a
+ Register an Interface with a Type that implements it as a multiton and create a The Interface to registerThe Type that implements the interfaceThe Type of the multiton scope
- A new created with the given parameters
+ A new created with the given parameters
@@ -1355,12 +1291,12 @@
Factory registration is invalidCreation of abstract methods are illegal in their current state
-
+
A that implements a
-
+
A that implements a
@@ -1368,11 +1304,24 @@
The of the implementation type
The of this
-
+
The that implements the that is registered with this
+
+
+ This is invoked when an instance of this type is created.
+ Can be set in the by calling
+
+
+
+
+ Pass an that will be invoked when an instance of this type is created
+
+ The
+ The current instance of this
+
A special that allows to set a as a callback that is called on
diff --git a/LightweightIocContainer/Registrations/DefaultRegistration.cs b/LightweightIocContainer/Registrations/DefaultRegistration.cs
index d680fc3..09d5307 100644
--- a/LightweightIocContainer/Registrations/DefaultRegistration.cs
+++ b/LightweightIocContainer/Registrations/DefaultRegistration.cs
@@ -3,19 +3,19 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
-using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
///
- /// The to register a for the Interface it implements
+ /// The to register a for the Interface it implements
///
/// The of the interface
- public class DefaultRegistration : TypedRegistrationBase, IDefaultRegistration
+ /// The of the implementation
+ public class DefaultRegistration : TypedRegistrationBase, IDefaultRegistration where TImplementation : TInterface
{
///
- /// The to register a for the Interface it implements
+ /// The to register a for the Interface it implements
///
/// The of the interface
/// The of the implementation
@@ -25,23 +25,5 @@ namespace LightweightIocContainer.Registrations
{
Name = $"{InterfaceType.Name}, {ImplementationType.Name}, Lifestyle: {Lifestyle.ToString()}";
}
-
- ///
- /// This is invoked when an instance of this type is created.
- /// Can be set in the by calling
- ///
- public Action OnCreateAction { get; private set; }
-
-
- ///
- /// Pass an that will be invoked when an instance of this is created
- ///
- /// The
- /// The current instance of this
- public IRegistrationBase OnCreate(Action action)
- {
- OnCreateAction = action;
- return this;
- }
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/Registrations/MultipleRegistration.cs b/LightweightIocContainer/Registrations/MultipleRegistration.cs
index bf57a5c..bfb6c6c 100644
--- a/LightweightIocContainer/Registrations/MultipleRegistration.cs
+++ b/LightweightIocContainer/Registrations/MultipleRegistration.cs
@@ -9,10 +9,11 @@ using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
///
- /// The base class for every to register multiple interfaces
+ /// The base class for every to register multiple interfaces
///
/// The first interface
- public abstract class MultipleRegistration : TypedRegistrationBase, IMultipleRegistration
+ /// The implementation
+ public abstract class MultipleRegistration : TypedRegistrationBase, IMultipleRegistration where TImplementation : TInterface1
{
///
/// The base class for every to register multiple interfaces
@@ -37,7 +38,8 @@ namespace LightweightIocContainer.Registrations
///
/// The first interface
/// The second interface
- public class MultipleRegistration : MultipleRegistration, IMultipleRegistration
+ /// The implementation
+ public class MultipleRegistration : MultipleRegistration, IMultipleRegistration where TImplementation : TInterface1, TInterface2
{
///
/// An to register multiple interfaces for on implementation type
@@ -51,25 +53,24 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List()
{
- new DefaultRegistration(interfaceType1, implementationType, lifestyle),
- new DefaultRegistration(interfaceType2, implementationType, lifestyle)
+ new DefaultRegistration(interfaceType1, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType2, implementationType, lifestyle)
};
}
///
- /// Pass an for each interface that will be invoked when instances of the types are created
+ /// Pass an that will be invoked when an instance of this type is created
///
- /// The first
- /// The second
- /// The current instance of this
- public IMultipleRegistration OnCreate(Action action1, Action action2)
+ /// The
+ /// The current instance of this
+ public override ITypedRegistrationBase OnCreate(Action action)
{
foreach (var registration in Registrations)
{
- if (registration is IDefaultRegistration interface2Registration)
- interface2Registration.OnCreate(action2);
- else if (registration is IDefaultRegistration interface1Registration)
- interface1Registration.OnCreate(action1);
+ if (registration is IDefaultRegistration interface2Registration)
+ interface2Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface1Registration)
+ interface1Registration.OnCreate(action);
}
return this;
@@ -82,7 +83,8 @@ namespace LightweightIocContainer.Registrations
/// The first interface
/// The second interface
/// The third interface
- public class MultipleRegistration : MultipleRegistration, IMultipleRegistration
+ /// The implementation
+ public class MultipleRegistration : MultipleRegistration, IMultipleRegistration where TImplementation : TInterface3, TInterface2, TInterface1
{
///
/// An to register multiple interfaces for on implementation type
@@ -97,29 +99,27 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List()
{
- new DefaultRegistration(interfaceType1, implementationType, lifestyle),
- new DefaultRegistration(interfaceType2, implementationType, lifestyle),
- new DefaultRegistration(interfaceType3, implementationType, lifestyle)
+ new DefaultRegistration(interfaceType1, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType2, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType3, implementationType, lifestyle)
};
}
///
- /// Pass an for each interface that will be invoked when instances of the types are created
+ /// Pass an that will be invoked when an instance of this type is created
///
- /// The first
- /// The second
- /// The third
- /// The current instance of this
- public IMultipleRegistration OnCreate(Action action1, Action action2, Action action3)
+ /// The
+ /// The current instance of this
+ public override ITypedRegistrationBase OnCreate(Action action)
{
foreach (var registration in Registrations)
{
- if (registration is IDefaultRegistration interface3Registration)
- interface3Registration.OnCreate(action3);
- else if (registration is IDefaultRegistration interface2Registration)
- interface2Registration.OnCreate(action2);
- else if (registration is IDefaultRegistration interface1Registration)
- interface1Registration.OnCreate(action1);
+ if (registration is IDefaultRegistration interface3Registration)
+ interface3Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface2Registration)
+ interface2Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface1Registration)
+ interface1Registration.OnCreate(action);
}
return this;
@@ -133,7 +133,8 @@ namespace LightweightIocContainer.Registrations
/// The second interface
/// The third interface
/// The fourth interface
- public class MultipleRegistration : MultipleRegistration, IMultipleRegistration
+ /// The implementation
+ public class MultipleRegistration : MultipleRegistration, IMultipleRegistration where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
{
///
/// An to register multiple interfaces for on implementation type
@@ -149,33 +150,30 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List()
{
- new DefaultRegistration(interfaceType1, implementationType, lifestyle),
- new DefaultRegistration(interfaceType2, implementationType, lifestyle),
- new DefaultRegistration(interfaceType3, implementationType, lifestyle),
- new DefaultRegistration(interfaceType4, implementationType, lifestyle)
+ new DefaultRegistration(interfaceType1, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType2, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType3, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType4, implementationType, lifestyle)
};
}
///
- /// Pass an for each interface that will be invoked when instances of the types are created
+ /// Pass an that will be invoked when an instance of this type is created
///
- /// The first
- /// The second
- /// The third
- /// The fourth
- /// The current instance of this
- public IMultipleRegistration OnCreate(Action action1, Action action2, Action action3, Action action4)
+ /// The
+ /// The current instance of this
+ public override ITypedRegistrationBase OnCreate(Action action)
{
foreach (var registration in Registrations)
{
- if (registration is IDefaultRegistration interface4Registration)
- interface4Registration.OnCreate(action4);
- else if (registration is IDefaultRegistration interface3Registration)
- interface3Registration.OnCreate(action3);
- else if (registration is IDefaultRegistration interface2Registration)
- interface2Registration.OnCreate(action2);
- else if (registration is IDefaultRegistration interface1Registration)
- interface1Registration.OnCreate(action1);
+ if (registration is IDefaultRegistration interface4Registration)
+ interface4Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface3Registration)
+ interface3Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface2Registration)
+ interface2Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface1Registration)
+ interface1Registration.OnCreate(action);
}
return this;
@@ -190,7 +188,8 @@ namespace LightweightIocContainer.Registrations
/// The third interface
/// The fourth interface
/// The fifth interface
- public class MultipleRegistration : MultipleRegistration, IMultipleRegistration
+ /// The implementation
+ public class MultipleRegistration : MultipleRegistration, IMultipleRegistration where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
{
///
/// An to register multiple interfaces for on implementation type
@@ -207,37 +206,33 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List()
{
- new DefaultRegistration(interfaceType1, implementationType, lifestyle),
- new DefaultRegistration(interfaceType2, implementationType, lifestyle),
- new DefaultRegistration(interfaceType3, implementationType, lifestyle),
- new DefaultRegistration(interfaceType4, implementationType, lifestyle),
- new DefaultRegistration(interfaceType5, implementationType, lifestyle)
+ new DefaultRegistration(interfaceType1, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType2, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType3, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType4, implementationType, lifestyle),
+ new DefaultRegistration(interfaceType5, implementationType, lifestyle)
};
}
///
- /// Pass an for each interface that will be invoked when instances of the types are created
+ /// Pass an that will be invoked when an instance of this type is created
///
- /// The first
- /// The second
- /// The third
- /// The fourth
- /// The fifth
- /// The current instance of this
- public IMultipleRegistration OnCreate(Action action1, Action action2, Action action3, Action action4, Action action5)
+ /// The
+ /// The current instance of this
+ public override ITypedRegistrationBase OnCreate(Action action)
{
foreach (var registration in Registrations)
{
- if (registration is IDefaultRegistration interface5Registration)
- interface5Registration.OnCreate(action5);
- else if (registration is IDefaultRegistration interface4Registration)
- interface4Registration.OnCreate(action4);
- else if (registration is IDefaultRegistration interface3Registration)
- interface3Registration.OnCreate(action3);
- else if (registration is IDefaultRegistration interface2Registration)
- interface2Registration.OnCreate(action2);
- else if (registration is IDefaultRegistration interface1Registration)
- interface1Registration.OnCreate(action1);
+ if (registration is IDefaultRegistration interface5Registration)
+ interface5Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface4Registration)
+ interface4Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface3Registration)
+ interface3Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface2Registration)
+ interface2Registration.OnCreate(action);
+ else if (registration is IDefaultRegistration interface1Registration)
+ interface1Registration.OnCreate(action);
}
return this;
diff --git a/LightweightIocContainer/Registrations/MultitonRegistration.cs b/LightweightIocContainer/Registrations/MultitonRegistration.cs
index 4727978..1e479e5 100644
--- a/LightweightIocContainer/Registrations/MultitonRegistration.cs
+++ b/LightweightIocContainer/Registrations/MultitonRegistration.cs
@@ -11,7 +11,8 @@ namespace LightweightIocContainer.Registrations
/// The registration that is used to register a multiton
///
/// The registered interface
- public class MultitonRegistration : DefaultRegistration, IMultitonRegistration
+ /// The registered implementation
+ public class MultitonRegistration : DefaultRegistration, IMultitonRegistration where TImplementation : TInterface
{
///
/// The registration that is used to register a multiton
diff --git a/LightweightIocContainer/Registrations/RegistrationFactory.cs b/LightweightIocContainer/Registrations/RegistrationFactory.cs
index 8f1c0f2..ef66ee8 100644
--- a/LightweightIocContainer/Registrations/RegistrationFactory.cs
+++ b/LightweightIocContainer/Registrations/RegistrationFactory.cs
@@ -22,15 +22,15 @@ namespace LightweightIocContainer.Registrations
}
///
- /// Register an Interface with a Type that implements it and create a
+ /// Register an Interface with a Type that implements it and create a
///
/// The Interface to register
/// The Type that implements the interface
- /// The for this
- /// A new created with the given parameters
- public IDefaultRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface
+ /// The for this
+ /// A new created with the given parameters
+ public IDefaultRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface
{
- return new DefaultRegistration(typeof(TInterface), typeof(TImplementation), lifestyle);
+ return new DefaultRegistration(typeof(TInterface), typeof(TImplementation), lifestyle);
}
///
@@ -41,9 +41,9 @@ namespace LightweightIocContainer.Registrations
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2
+ public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2
{
- return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle);
+ return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle);
}
///
@@ -55,9 +55,9 @@ namespace LightweightIocContainer.Registrations
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3
+ public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3
{
- return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle);
+ return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle);
}
///
@@ -70,9 +70,9 @@ namespace LightweightIocContainer.Registrations
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4
+ public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4
{
- return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle);
+ return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle);
}
///
@@ -86,9 +86,9 @@ namespace LightweightIocContainer.Registrations
/// The that implements both interfaces
/// The for this
/// The created
- public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5
+ public IMultipleRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5
{
- return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle);
+ return new MultipleRegistration(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle);
}
///
@@ -103,15 +103,15 @@ namespace LightweightIocContainer.Registrations
}
///
- /// Register an Interface with a Type that implements it as a multiton and create a
+ /// Register an Interface with a Type that implements it as a multiton and create a
///
/// The Interface to register
/// The Type that implements the interface
/// The Type of the multiton scope
- /// A new created with the given parameters
- public IMultitonRegistration RegisterMultiton() where TImplementation : TInterface
+ /// A new created with the given parameters
+ public IMultitonRegistration RegisterMultiton() where TImplementation : TInterface
{
- return new MultitonRegistration(typeof(TInterface), typeof(TImplementation), typeof(TScope));
+ return new MultitonRegistration(typeof(TInterface), typeof(TImplementation), typeof(TScope));
}
///
diff --git a/LightweightIocContainer/Registrations/TypedRegistrationBase.cs b/LightweightIocContainer/Registrations/TypedRegistrationBase.cs
index f9efe26..68d359c 100644
--- a/LightweightIocContainer/Registrations/TypedRegistrationBase.cs
+++ b/LightweightIocContainer/Registrations/TypedRegistrationBase.cs
@@ -3,14 +3,16 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
+using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
+using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
namespace LightweightIocContainer.Registrations
{
///
/// A that implements a
///
- public abstract class TypedRegistrationBase : RegistrationBase, ITypedRegistrationBase
+ public abstract class TypedRegistrationBase : RegistrationBase, ITypedRegistrationBase where TImplementation : TInterface
{
///
/// A that implements a
@@ -28,5 +30,22 @@ namespace LightweightIocContainer.Registrations
/// The that implements the that is registered with this
///
public Type ImplementationType { get; }
+
+ ///
+ /// This is invoked when an instance of this type is created.
+ /// Can be set in the by calling
+ ///
+ public Action