#33: remove IOnCreate from iRegistrationBase

pull/37/head
Simon Gockner 6 years ago
parent cb03bae119
commit 3f83b544d8
  1. 2
      LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs
  2. 23
      LightweightIocContainer/Registrations/RegistrationBase.cs

@ -10,7 +10,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// The <see cref="IRegistrationBase{TInterface}"/> that is used to register an Interface /// The <see cref="IRegistrationBase{TInterface}"/> that is used to register an Interface
/// </summary> /// </summary>
/// <typeparam name="TInterface">The registered Interface</typeparam> /// <typeparam name="TInterface">The registered Interface</typeparam>
public interface IRegistrationBase<TInterface> : IRegistration, IOnCreate<TInterface>, IWithParameters<TInterface> public interface IRegistrationBase<TInterface> : IRegistration, IWithParameters<TInterface>
{ {
/// <summary> /// <summary>
/// The Lifestyle of Instances that are created with this <see cref="IRegistrationBase{TInterface}"/> /// The Lifestyle of Instances that are created with this <see cref="IRegistrationBase{TInterface}"/>

@ -43,25 +43,6 @@ namespace LightweightIocContainer.Registrations
/// </summary> /// </summary>
public Lifestyle Lifestyle { get; } public Lifestyle Lifestyle { get; }
/// <summary>
/// This <see cref="Action{T}"/> is invoked when an instance of this type is created.
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="OnCreate"/></para>
/// </summary>
public Action<TInterface> OnCreateAction { get; private set; }
/// <summary>
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this <see cref="Type"/> is created
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns>
public IRegistrationBase<TInterface> OnCreate(Action<TInterface> action)
{
OnCreateAction = action;
return this;
}
/// <summary> /// <summary>
/// An <see cref="Array"/> of parameters that are used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// An <see cref="Array"/> of parameters that are used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="WithParameters(object[])"/></para> /// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="WithParameters(object[])"/></para>
@ -75,7 +56,7 @@ namespace LightweightIocContainer.Registrations
/// <param name="parameters">The parameters</param> /// <param name="parameters">The parameters</param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns>
/// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception> /// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception>
public IRegistrationBase<TInterface> WithParameters(params object[] parameters) public virtual IRegistrationBase<TInterface> WithParameters(params object[] parameters)
{ {
if (Parameters != null) if (Parameters != null)
throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType})."); throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType}).");
@ -94,7 +75,7 @@ namespace LightweightIocContainer.Registrations
/// <param name="parameters">The parameters with their position</param> /// <param name="parameters">The parameters with their position</param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns>
/// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception> /// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception>
public IRegistrationBase<TInterface> WithParameters(params (int index, object parameter)[] parameters) public virtual IRegistrationBase<TInterface> WithParameters(params (int index, object parameter)[] parameters)
{ {
if (Parameters != null) if (Parameters != null)
throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType})."); throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType}).");

Loading…
Cancel
Save