diff --git a/LightweightIocContainer/Interfaces/Registrations/IDefaultRegistration.cs b/LightweightIocContainer/Interfaces/Registrations/IDefaultRegistration.cs index 3597927..508bc63 100644 --- a/LightweightIocContainer/Interfaces/Registrations/IDefaultRegistration.cs +++ b/LightweightIocContainer/Interfaces/Registrations/IDefaultRegistration.cs @@ -3,6 +3,7 @@ // Copyright(c) 2019 SimonG. All Rights Reserved. using System; +using LightweightIocContainer.Interfaces.Registrations.FluentProviders; namespace LightweightIocContainer.Interfaces.Registrations { @@ -10,11 +11,8 @@ namespace LightweightIocContainer.Interfaces.Registrations /// The to register a for the Interface it implements /// /// The of the interface - public interface IDefaultRegistration : IRegistrationBase + public interface IDefaultRegistration : ITypedRegistrationBase, IOnCreate { - /// - /// The that implements the that is registered with this - /// - Type ImplementationType { get; } + } } \ No newline at end of file diff --git a/LightweightIocContainer/Registrations/DefaultRegistration.cs b/LightweightIocContainer/Registrations/DefaultRegistration.cs index f8c5c47..d680fc3 100644 --- a/LightweightIocContainer/Registrations/DefaultRegistration.cs +++ b/LightweightIocContainer/Registrations/DefaultRegistration.cs @@ -3,6 +3,7 @@ // Copyright(c) 2019 SimonG. All Rights Reserved. using System; +using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Registrations; namespace LightweightIocContainer.Registrations @@ -11,7 +12,7 @@ namespace LightweightIocContainer.Registrations /// The to register a for the Interface it implements /// /// The of the interface - public class DefaultRegistration : RegistrationBase, IDefaultRegistration + public class DefaultRegistration : TypedRegistrationBase, IDefaultRegistration { /// /// The to register a for the Interface it implements @@ -20,15 +21,27 @@ namespace LightweightIocContainer.Registrations /// The of the implementation /// The of the public DefaultRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle) - : base(interfaceType, lifestyle) + : base(interfaceType, implementationType, lifestyle) { - ImplementationType = implementationType; Name = $"{InterfaceType.Name}, {ImplementationType.Name}, Lifestyle: {Lifestyle.ToString()}"; } /// - /// 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 /// - public Type ImplementationType { get; } + 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