diff --git a/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs b/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs new file mode 100644 index 0000000..c4556a4 --- /dev/null +++ b/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs @@ -0,0 +1,29 @@ +// Author: Simon Gockner +// Created: 2019-12-07 +// Copyright(c) 2019 SimonG. All Rights Reserved. + +using System; +using LightweightIocContainer.Interfaces.Installers; + +namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders +{ + /// + /// Provides an method to an + /// + /// The registered interface + 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); + } +} \ No newline at end of file diff --git a/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IWithParameters.cs b/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IWithParameters.cs new file mode 100644 index 0000000..0bb2a9e --- /dev/null +++ b/LightweightIocContainer/Interfaces/Registrations/FluentProviders/IWithParameters.cs @@ -0,0 +1,41 @@ +// Author: Simon Gockner +// Created: 2019-12-07 +// Copyright(c) 2019 SimonG. All Rights Reserved. + +using System; +using LightweightIocContainer.Exceptions; +using LightweightIocContainer.Interfaces.Installers; + +namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders +{ + /// + /// Provides a method to an + /// + /// The registered interface + public interface IWithParameters + { + /// + /// An of parameters that are used to an instance of this + /// Can be set in the by calling + /// + object[] Parameters { get; } + + /// + /// Pass parameters that will be used to an instance of this + /// Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving + /// + /// The parameters + /// The current instance of this + /// are already set or no parameters given + IRegistrationBase WithParameters(params object[] parameters); + + /// + /// Pass parameters that will be used to an instance of this + /// Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving + /// + /// The parameters with their position + /// The current instance of this + /// are already set or no parameters given + IRegistrationBase WithParameters(params (int index, object parameter)[] parameters); + } +} \ No newline at end of file diff --git a/LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs b/LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs index 7f7e3dd..6135eed 100644 --- a/LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs +++ b/LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs @@ -2,9 +2,7 @@ // Created: 2019-05-20 // Copyright(c) 2019 SimonG. All Rights Reserved. -using System; -using LightweightIocContainer.Exceptions; -using LightweightIocContainer.Interfaces.Installers; +using LightweightIocContainer.Interfaces.Registrations.FluentProviders; namespace LightweightIocContainer.Interfaces.Registrations { @@ -12,49 +10,11 @@ namespace LightweightIocContainer.Interfaces.Registrations /// The that is used to register an Interface /// /// The registered Interface - public interface IRegistrationBase : IRegistration + public interface IRegistrationBase : IRegistration, IOnCreate, IWithParameters { /// /// The Lifestyle of Instances that are created with this /// Lifestyle Lifestyle { get; } - - /// - /// 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); - - /// - /// An of parameters that are used to an instance of this - /// Can be set in the by calling - /// - object[] Parameters { get; } - - /// - /// Pass parameters that will be used to an instance of this - /// Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving - /// - /// The parameters - /// The current instance of this - /// are already set or no parameters given - IRegistrationBase WithParameters(params object[] parameters); - - /// - /// Pass parameters that will be used to an instance of this - /// Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving - /// - /// The parameters with their position - /// The current instance of this - /// are already set or no parameters given - IRegistrationBase WithParameters(params (int index, object parameter)[] parameters); - } } \ No newline at end of file diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index dd6b580..342804a 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -12,6 +12,7 @@ using LightweightIocContainer.Exceptions; using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Registrations; +using LightweightIocContainer.Interfaces.Registrations.FluentProviders; using LightweightIocContainer.Registrations; namespace LightweightIocContainer @@ -343,12 +344,12 @@ namespace LightweightIocContainer } /// - /// Update the given arguments with the of the given + /// Update the given arguments with the of the given /// /// The given /// The of the given /// The constructor arguments - /// The argument list updated with the + /// The argument list updated with the private object[] UpdateArgumentsWithRegistrationParameters(IRegistrationBase registration, object[] arguments) { if (arguments != null && arguments.Any()) //if more arguments were passed to resolve