On create pass implementation #34
pull/43/head
Simon G 6 years ago committed by GitHub
commit ea6b26abce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      LightweightIocContainer/Interfaces/IIocContainer.cs
  2. 93
      LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs
  3. 6
      LightweightIocContainer/Interfaces/Registrations/IDefaultRegistration.cs
  4. 20
      LightweightIocContainer/Interfaces/Registrations/IMultipleRegistration.cs
  5. 15
      LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
  6. 11
      LightweightIocContainer/Interfaces/Registrations/ITypedRegistrationBase.cs
  7. 39
      LightweightIocContainer/IocContainer.cs
  8. 269
      LightweightIocContainer/LightweightIocContainer.xml
  9. 26
      LightweightIocContainer/Registrations/DefaultRegistration.cs
  10. 143
      LightweightIocContainer/Registrations/MultipleRegistration.cs
  11. 3
      LightweightIocContainer/Registrations/MultitonRegistration.cs
  12. 34
      LightweightIocContainer/Registrations/RegistrationFactory.cs
  13. 21
      LightweightIocContainer/Registrations/TypedRegistrationBase.cs
  14. 52
      Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs
  15. 27
      Test.LightweightIocContainer/OnCreateTest.cs

@ -27,7 +27,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IRegistration"/></returns>
IDefaultRegistration<TInterface> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface;
IDefaultRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface;
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
@ -37,7 +37,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
IMultipleRegistration<TInterface1, TInterface2> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1;
IMultipleRegistration<TInterface1, TInterface2, TImplementation> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1;
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
@ -48,7 +48,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TInterface3> Register<TInterface1, TInterface2, TInterface3, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1;
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> Register<TInterface1, TInterface2, TInterface3, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1;
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
@ -60,7 +60,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1;
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1;
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
@ -73,7 +73,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1;
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1;
/// <summary>
/// Register a <see cref="Type"/> without an interface
@ -90,7 +90,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <typeparam name="TScope">The Type of the multiton scope</typeparam>
/// <returns>The created <see cref="IRegistration"/></returns>
IMultitonRegistration<TInterface> RegisterMultiton<TInterface, TImplementation, TScope>() where TImplementation : TInterface;
IMultitonRegistration<TInterface, TImplementation> RegisterMultiton<TInterface, TImplementation, TScope>() where TImplementation : TInterface;
/// <summary>
/// Register an Interface as an abstract typed factory

@ -8,98 +8,29 @@ using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
{
/// <summary>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IRegistrationBase{TInterface}"/>
/// Provides an <see cref="OnCreateAction"/> to the generic <see cref="IOnCreate{TInterface, TImplementation}"/>
/// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam>
public interface IOnCreate<TInterface>
public interface IOnCreate
{
/// <summary>
/// This <see cref="Action"/> 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>
Action<TInterface> OnCreateAction { get; }
/// <summary>
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns>
IRegistrationBase<TInterface> OnCreate(Action<TInterface> action);
}
/// <summary>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IMultipleRegistration{TInterface1,TInterface2}"/>
/// </summary>
/// <typeparam name="TInterface1">The first registered interface</typeparam>
/// <typeparam name="TInterface2">The second registered interface</typeparam>
public interface IOnCreate<TInterface1, TInterface2>
{
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
IMultipleRegistration<TInterface1, TInterface2> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2);
}
/// <summary>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/>
/// </summary>
/// <typeparam name="TInterface1">The first registered interface</typeparam>
/// <typeparam name="TInterface2">The second registered interface</typeparam>
/// <typeparam name="TInterface3">The third registered interface</typeparam>
public interface IOnCreate<TInterface1, TInterface2, TInterface3>
{
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <param name="action3">The third <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TInterface3> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2, Action<TInterface3> action3);
}
/// <summary>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/>
/// </summary>
/// <typeparam name="TInterface1">The first registered interface</typeparam>
/// <typeparam name="TInterface2">The second registered interface</typeparam>
/// <typeparam name="TInterface3">The third registered interface</typeparam>
/// <typeparam name="TInterface4">The fourth registered interface</typeparam>
public interface IOnCreate<TInterface1, TInterface2, TInterface3, TInterface4>
{
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IOnCreate{TInterface, TImplementation}.OnCreate"/></para>
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <param name="action3">The third <see cref="Action{T}"/></param>
/// <param name="action4">The fourth <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2, Action<TInterface3> action3, Action<TInterface4> action4);
Action<object> OnCreateAction { get; }
}
/// <summary>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IRegistrationBase{TInterface}"/>
/// </summary>
/// <typeparam name="TInterface1">The first registered interface</typeparam>
/// <typeparam name="TInterface2">The second registered interface</typeparam>
/// <typeparam name="TInterface3">The third registered interface</typeparam>
/// <typeparam name="TInterface4">The fourth registered interface</typeparam>
/// <typeparam name="TInterface5">The fifth registered interface</typeparam>
public interface IOnCreate<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5>
/// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam>
public interface IOnCreate<TInterface, TImplementation> : IOnCreate where TImplementation : TInterface
{
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <param name="action3">The third <see cref="Action{T}"/></param>
/// <param name="action4">The fourth <see cref="Action{T}"/></param>
/// <param name="action5">The fifth <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2, Action<TInterface3> action3, Action<TInterface4> action4, Action<TInterface5> action5);
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
ITypedRegistrationBase<TInterface, TImplementation> OnCreate(Action<TImplementation> action);
}
}

@ -3,15 +3,15 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// The <see cref="IDefaultRegistration{TInterface}"/> to register a <see cref="Type"/> for the Interface it implements
/// The <see cref="IDefaultRegistration{TInterface,TImplementation}"/> to register a <see cref="Type"/> for the Interface it implements
/// </summary>
/// <typeparam name="TInterface">The <see cref="Type"/> of the interface</typeparam>
public interface IDefaultRegistration<TInterface> : ITypedRegistrationBase<TInterface>, IOnCreate<TInterface>
/// <typeparam name="TImplementation">The <see cref="Type"/> of the implementation</typeparam>
public interface IDefaultRegistration<TInterface, TImplementation> : ITypedRegistrationBase<TInterface, TImplementation> where TImplementation : TInterface
{
}

@ -3,18 +3,18 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System.Collections.Generic;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// The base interface for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces
/// The base interface for every <see cref="IMultipleRegistration{TInterface1,TInterface2,TImplementation}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
public interface IMultipleRegistration<TInterface1> : ITypedRegistrationBase<TInterface1>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TImplementation> : ITypedRegistrationBase<TInterface1, TImplementation> where TImplementation : TInterface1
{
/// <summary>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1}"/>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1,TImplementation}"/>
/// </summary>
List<IRegistration> Registrations { get; }
}
@ -24,7 +24,8 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2> : IMultipleRegistration<TInterface1>, IOnCreate<TInterface1, TInterface2>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2
{
}
@ -35,7 +36,8 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3> : IMultipleRegistration<TInterface1>, IOnCreate<TInterface1, TInterface2, TInterface3>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3
{
}
@ -47,7 +49,8 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> : IMultipleRegistration<TInterface1>, IOnCreate<TInterface1, TInterface2, TInterface3, TInterface4>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4
{
}
@ -60,7 +63,8 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam>
/// <typeparam name="TInterface5">The fifth interface</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> : IMultipleRegistration<TInterface1>, IOnCreate<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5
{
}

@ -7,14 +7,23 @@ using System;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// The registration that is used to register a multiton
/// A base <see cref="IMultitonRegistration{TInterface}"/> without implementation
/// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam>
public interface IMultitonRegistration<TInterface> : IDefaultRegistration<TInterface>
public interface IMultitonRegistration<TInterface> : IRegistrationBase<TInterface>
{
/// <summary>
/// The <see cref="Type"/> of the multiton scope
/// </summary>
Type Scope { get; }
}
/// <summary>
/// The registration that is used to register a multiton
/// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam>
public interface IMultitonRegistration<TInterface, TImplementation> : IMultitonRegistration<TInterface>, IDefaultRegistration<TInterface, TImplementation> where TImplementation : TInterface
{
}
}

@ -3,11 +3,12 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
/// A base <see cref="ITypedRegistrationBase{TInterface}"/> without implementation
/// </summary>
public interface ITypedRegistrationBase<TInterface> : IRegistrationBase<TInterface>
{
@ -16,4 +17,12 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// </summary>
Type ImplementationType { get; }
}
/// <summary>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
/// </summary>
public interface ITypedRegistrationBase<TInterface, TImplementation> : ITypedRegistrationBase<TInterface>, IOnCreate<TInterface, TImplementation> where TImplementation : TInterface
{
}
}

@ -60,9 +60,9 @@ namespace LightweightIocContainer
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IRegistration"/></returns>
public IDefaultRegistration<TInterface> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface
public IDefaultRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface
{
IDefaultRegistration<TInterface> registration = _registrationFactory.Register<TInterface, TImplementation>(lifestyle);
IDefaultRegistration<TInterface, TImplementation> registration = _registrationFactory.Register<TInterface, TImplementation>(lifestyle);
Register(registration);
return registration;
@ -76,9 +76,9 @@ namespace LightweightIocContainer
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1
public IMultipleRegistration<TInterface1, TInterface2, TImplementation> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1
{
IMultipleRegistration<TInterface1, TInterface2> multipleRegistration = _registrationFactory.Register<TInterface1, TInterface2, TImplementation>(lifestyle);
IMultipleRegistration<TInterface1, TInterface2, TImplementation> multipleRegistration = _registrationFactory.Register<TInterface1, TInterface2, TImplementation>(lifestyle);
Register(multipleRegistration);
return multipleRegistration;
@ -93,9 +93,9 @@ namespace LightweightIocContainer
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3> Register<TInterface1, TInterface2, TInterface3, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> Register<TInterface1, TInterface2, TInterface3, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1
{
IMultipleRegistration<TInterface1, TInterface2, TInterface3> multipleRegistration =
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> multipleRegistration =
_registrationFactory.Register<TInterface1, TInterface2, TInterface3, TImplementation>(lifestyle);
Register(multipleRegistration);
@ -112,9 +112,9 @@ namespace LightweightIocContainer
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
{
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> multipleRegistration =
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> multipleRegistration =
_registrationFactory.Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(lifestyle);
Register(multipleRegistration);
@ -132,9 +132,9 @@ namespace LightweightIocContainer
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
{
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> multipleRegistration =
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> multipleRegistration =
_registrationFactory.Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(lifestyle);
Register(multipleRegistration);
@ -162,9 +162,9 @@ namespace LightweightIocContainer
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <typeparam name="TScope">The Type of the multiton scope</typeparam>
/// <returns>The created <see cref="IRegistration"/></returns>
public IMultitonRegistration<TInterface> RegisterMultiton<TInterface, TImplementation, TScope>() where TImplementation : TInterface
public IMultitonRegistration<TInterface, TImplementation> RegisterMultiton<TInterface, TImplementation, TScope>() where TImplementation : TInterface
{
IMultitonRegistration<TInterface> registration = _registrationFactory.RegisterMultiton<TInterface, TImplementation, TScope>();
IMultitonRegistration<TInterface, TImplementation> registration = _registrationFactory.RegisterMultiton<TInterface, TImplementation, TScope>();
Register(registration);
return registration;
@ -203,7 +203,7 @@ namespace LightweightIocContainer
/// </summary>
/// <param name="registration">The given <see cref="IRegistration"/></param>
/// <exception cref="MultipleRegistrationException">The <see cref="Type"/> is already registered in this <see cref="IocContainer"/></exception>
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
}
/// <summary>
/// Register all <see cref="IMultipleRegistration{TInterface1}.Registrations"/> from an <see cref="IMultipleRegistration{TInterface1}"/>
/// Register all <see cref="IMultipleRegistration{TInterface1,TImplementation}.Registrations"/> from an <see cref="IMultipleRegistration{TInterface1,TImplementation}"/>
/// </summary>
/// <typeparam name="TInterface1">The <see cref="Type"/> of the first registered interface</typeparam>
/// <param name="multipleRegistration">The <see cref="IMultipleRegistration{TInterface1}"/></param>
private void Register<TInterface1>(IMultipleRegistration<TInterface1> multipleRegistration)
/// <typeparam name="TImplementation">The <see cref="Type"/> of the registered implementation</typeparam>
/// <param name="multipleRegistration">The <see cref="IMultipleRegistration{TInterface1,TImplementation}"/></param>
private void Register<TInterface1, TImplementation>(IMultipleRegistration<TInterface1, TImplementation> 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<T> defaultRegistration)
if (registration is ITypedRegistrationBase<T> 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<T> onCreateRegistration)
if (registration is IOnCreate onCreateRegistration)
onCreateRegistration.OnCreateAction?.Invoke(instance); //TODO: Allow async OnCreateAction?
return instance;
@ -445,7 +446,7 @@ namespace LightweightIocContainer
/// <param name="registration">The <see cref="IRegistrationBase{TInterface}"/> of the given <see cref="Type"/></param>
/// <param name="arguments">The constructor arguments</param>
/// <returns>The argument list updated with the <see cref="IWithParameters{TInterface}.Parameters"/></returns>
private object[] UpdateArgumentsWithRegistrationParameters<T>(IRegistrationBase<T> registration, object[] arguments)
private object[] UpdateArgumentsWithRegistrationParameters<T>(IWithParameters<T> registration, object[] arguments)
{
if (arguments != null && arguments.Any()) //if more arguments were passed to resolve
{

@ -473,96 +473,30 @@
</summary>
<param name="container">The current <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`1">
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate">
<summary>
Provides an <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`1.OnCreate(System.Action{`0})"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
Provides an <see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate.OnCreateAction"/> to the generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2"/>
</summary>
<typeparam name="TInterface">The registered interface</typeparam>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`1.OnCreateAction">
<member name="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate.OnCreateAction">
<summary>
This <see cref="T:System.Action"/> is invoked when an instance of this type is created.
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`1.OnCreate(System.Action{`0})"/></para>
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`1})"/></para>
</summary>
</member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`1.OnCreate(System.Action{`0})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2">
<summary>
Provides an <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`0},System.Action{`1})"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/>
Provides an <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`1})"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
</summary>
<typeparam name="TInterface1">The first registered interface</typeparam>
<typeparam name="TInterface2">The second registered interface</typeparam>
</member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`0},System.Action{`1})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`3">
<summary>
Provides an <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`3.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2})"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/>
</summary>
<typeparam name="TInterface1">The first registered interface</typeparam>
<typeparam name="TInterface2">The second registered interface</typeparam>
<typeparam name="TInterface3">The third registered interface</typeparam>
</member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`3.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<param name="action3">The third <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`4">
<summary>
Provides an <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`4.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2},System.Action{`3})"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/>
</summary>
<typeparam name="TInterface1">The first registered interface</typeparam>
<typeparam name="TInterface2">The second registered interface</typeparam>
<typeparam name="TInterface3">The third registered interface</typeparam>
<typeparam name="TInterface4">The fourth registered interface</typeparam>
</member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`4.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2},System.Action{`3})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<param name="action3">The third <see cref="T:System.Action`1"/></param>
<param name="action4">The fourth <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`5">
<summary>
Provides an <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`5.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2},System.Action{`3},System.Action{`4})"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/>
</summary>
<typeparam name="TInterface1">The first registered interface</typeparam>
<typeparam name="TInterface2">The second registered interface</typeparam>
<typeparam name="TInterface3">The third registered interface</typeparam>
<typeparam name="TInterface4">The fourth registered interface</typeparam>
<typeparam name="TInterface5">The fifth registered interface</typeparam>
<typeparam name="TInterface">The registered interface</typeparam>
<typeparam name="TImplementation">The registered implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`5.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2},System.Action{`3},System.Action{`4})">
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`1})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<param name="action3">The third <see cref="T:System.Action`1"/></param>
<param name="action4">The fourth <see cref="T:System.Action`1"/></param>
<param name="action5">The fifth <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1">
<summary>
@ -594,39 +528,43 @@
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns>
<exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters"/> are already set or no parameters given</exception>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`1">
<member name="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2">
<summary>
The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`1"/> to register a <see cref="T:System.Type"/> for the Interface it implements
The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/> to register a <see cref="T:System.Type"/> for the Interface it implements
</summary>
<typeparam name="TInterface">The <see cref="T:System.Type"/> of the interface</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> of the implementation</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1">
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2">
<summary>
The base interface for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/> to register multiple interfaces
The base interface for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/> to register multiple interfaces
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1.Registrations">
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2.Registrations">
<summary>
A <see cref="T:System.Collections.Generic.List`1"/> of <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>s that are registered within this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1"/>
A <see cref="T:System.Collections.Generic.List`1"/> of <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>s that are registered within this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2">
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3">
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4">
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -634,8 +572,9 @@
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TInterface4">The fourth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5">
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`6">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -644,18 +583,25 @@
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TInterface4">The fourth interface</typeparam>
<typeparam name="TInterface5">The fifth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1">
<summary>
The registration that is used to register a multiton
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"/> without implementation
</summary>
<typeparam name="TInterface">The registered interface</typeparam>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1.Scope">
<summary>
The <see cref="T:System.Type"/> of the multiton scope
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`2">
<summary>
The registration that is used to register a multiton
</summary>
<typeparam name="TInterface">The registered interface</typeparam>
<typeparam name="TImplementation">The registered implementation</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IRegistration">
<summary>
The base registration that is used to register an Interface
@ -713,7 +659,7 @@
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`1">
<summary>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/>
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`1"/> without implementation
</summary>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`1.ImplementationType">
@ -721,6 +667,11 @@
The <see cref="T:System.Type"/> that implements the <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2">
<summary>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IUnitTestCallbackRegistration`1">
<summary>
A special <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> that allows to set a <see cref="T:LightweightIocContainer.ResolveCallback`1"/> as a callback that is called on <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/>
@ -848,12 +799,13 @@
<param name="registration">The given <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<exception cref="T:LightweightIocContainer.Exceptions.MultipleRegistrationException">The <see cref="T:System.Type"/> is already registered in this <see cref="T:LightweightIocContainer.IocContainer"/></exception>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``1(LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration{``0})">
<member name="M:LightweightIocContainer.IocContainer.Register``2(LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration{``0,``1})">
<summary>
Register all <see cref="P:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1.Registrations"/> from an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1"/>
Register all <see cref="P:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2.Registrations"/> from an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/>
</summary>
<typeparam name="TInterface1">The <see cref="T:System.Type"/> of the first registered interface</typeparam>
<param name="multipleRegistration">The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1"/></param>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> of the registered implementation</typeparam>
<param name="multipleRegistration">The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></param>
</member>
<member name="M:LightweightIocContainer.IocContainer.Resolve``1">
<summary>
@ -923,7 +875,7 @@
<param name="resolveStack">The current resolve stack</param>
<returns>A newly created instance of the given <see cref="T:System.Type"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.UpdateArgumentsWithRegistrationParameters``1(LightweightIocContainer.Interfaces.Registrations.IRegistrationBase{``0},System.Object[])">
<member name="M:LightweightIocContainer.IocContainer.UpdateArgumentsWithRegistrationParameters``1(LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters{``0},System.Object[])">
<summary>
Update the given arguments with the <see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters"/> of the given <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
</summary>
@ -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.
</summary>
</member>
<member name="T:LightweightIocContainer.Registrations.DefaultRegistration`1">
<member name="T:LightweightIocContainer.Registrations.DefaultRegistration`2">
<summary>
The <see cref="T:LightweightIocContainer.Registrations.DefaultRegistration`1"/> to register a <see cref="T:System.Type"/> for the Interface it implements
The <see cref="T:LightweightIocContainer.Registrations.DefaultRegistration`2"/> to register a <see cref="T:System.Type"/> for the Interface it implements
</summary>
<typeparam name="TInterface">The <see cref="T:System.Type"/> of the interface</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/>of the implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.DefaultRegistration`1.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<member name="M:LightweightIocContainer.Registrations.DefaultRegistration`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
The <see cref="T:LightweightIocContainer.Registrations.DefaultRegistration`1"/> to register a <see cref="T:System.Type"/> for the Interface it implements
The <see cref="T:LightweightIocContainer.Registrations.DefaultRegistration`2"/> to register a <see cref="T:System.Type"/> for the Interface it implements
</summary>
<param name="interfaceType">The <see cref="T:System.Type"/> of the interface</param>
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of the <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.DefaultRegistration`1.OnCreateAction">
<summary>
This <see cref="T:System.Action`1"/> is invoked when an instance of this type is created.
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Registrations.DefaultRegistration`1.OnCreate(System.Action{`0})"/></para>
</summary>
</member>
<member name="M:LightweightIocContainer.Registrations.DefaultRegistration`1.OnCreate(System.Action{`0})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this <see cref="T:System.Type"/> is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`1">
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`2">
<summary>
The base class for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/> to register multiple interfaces
The base class for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/> to register multiple interfaces
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`1.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
The base class for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/> to register multiple interfaces
</summary>
@ -1021,19 +962,20 @@
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.MultipleRegistration`1.Registrations">
<member name="P:LightweightIocContainer.Registrations.MultipleRegistration`2.Registrations">
<summary>
A <see cref="T:System.Collections.Generic.List`1"/> of <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>s that are registered within this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`2">
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`3">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`2.#ctor(System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.#ctor(System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -1042,23 +984,23 @@
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`2.OnCreate(System.Action{`0},System.Action{`1})">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.OnCreate(System.Action{`2})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></returns>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`3">
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`4">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.#ctor(System.Type,System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.#ctor(System.Type,System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -1068,16 +1010,14 @@
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2})">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.OnCreate(System.Action{`3})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<param name="action3">The third <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></returns>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`4">
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`5">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -1085,8 +1025,9 @@
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TInterface4">The fourth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.#ctor(System.Type,System.Type,System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.#ctor(System.Type,System.Type,System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -1097,17 +1038,14 @@
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2},System.Action{`3})">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.OnCreate(System.Action{`4})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<param name="action3">The third <see cref="T:System.Action`1"/></param>
<param name="action4">The fourth <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></returns>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`5">
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`6">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -1116,8 +1054,9 @@
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TInterface4">The fourth interface</typeparam>
<typeparam name="TInterface5">The fifth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.#ctor(System.Type,System.Type,System.Type,System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`6.#ctor(System.Type,System.Type,System.Type,System.Type,System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
</summary>
@ -1129,24 +1068,21 @@
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.OnCreate(System.Action{`0},System.Action{`1},System.Action{`2},System.Action{`3},System.Action{`4})">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`6.OnCreate(System.Action{`5})">
<summary>
Pass an <see cref="T:System.Action`1"/> for each interface that will be invoked when instances of the types are created
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action1">The first <see cref="T:System.Action`1"/></param>
<param name="action2">The second <see cref="T:System.Action`1"/></param>
<param name="action3">The third <see cref="T:System.Action`1"/></param>
<param name="action4">The fourth <see cref="T:System.Action`1"/></param>
<param name="action5">The fifth <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></returns>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultitonRegistration`1">
<member name="T:LightweightIocContainer.Registrations.MultitonRegistration`2">
<summary>
The registration that is used to register a multiton
</summary>
<typeparam name="TInterface">The registered interface</typeparam>
<typeparam name="TImplementation">The registered implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultitonRegistration`1.#ctor(System.Type,System.Type,System.Type)">
<member name="M:LightweightIocContainer.Registrations.MultitonRegistration`2.#ctor(System.Type,System.Type,System.Type)">
<summary>
The registration that is used to register a multiton
</summary>
@ -1154,7 +1090,7 @@
<param name="implementationType">The <see cref="T:System.Type"/> of the Implementation</param>
<param name="scope">The <see cref="T:System.Type"/> of the Multiton Scope</param>
</member>
<member name="P:LightweightIocContainer.Registrations.MultitonRegistration`1.Scope">
<member name="P:LightweightIocContainer.Registrations.MultitonRegistration`2.Scope">
<summary>
The <see cref="T:System.Type"/> of the multiton scope
</summary>
@ -1218,12 +1154,12 @@
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``2(LightweightIocContainer.Lifestyle)">
<summary>
Register an Interface with a Type that implements it and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`1"/>
Register an Interface with a Type that implements it and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/>
</summary>
<typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`1"/></param>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`1"/> with the given parameters</returns>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/></param>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/> with the given parameters</returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``3(LightweightIocContainer.Lifestyle)">
<summary>
@ -1281,12 +1217,12 @@
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.RegisterMultiton``3">
<summary>
Register an Interface with a Type that implements it as a multiton and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"/>
Register an Interface with a Type that implements it as a multiton and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`2"/>
</summary>
<typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</typeparam>
<typeparam name="TScope">The Type of the multiton scope</typeparam>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"/> with the given parameters</returns>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`2"/> with the given parameters</returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.RegisterFactory``1">
<summary>
@ -1355,12 +1291,12 @@
<exception cref="T:LightweightIocContainer.Exceptions.InvalidFactoryRegistrationException">Factory registration is invalid</exception>
<exception cref="T:LightweightIocContainer.Exceptions.IllegalAbstractMethodCreationException">Creation of abstract methods are illegal in their current state</exception>
</member>
<member name="T:LightweightIocContainer.Registrations.TypedRegistrationBase`1">
<member name="T:LightweightIocContainer.Registrations.TypedRegistrationBase`2">
<summary>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/>
</summary>
</member>
<member name="M:LightweightIocContainer.Registrations.TypedRegistrationBase`1.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<member name="M:LightweightIocContainer.Registrations.TypedRegistrationBase`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/>
</summary>
@ -1368,11 +1304,24 @@
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation type</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.TypedRegistrationBase`1.ImplementationType">
<member name="P:LightweightIocContainer.Registrations.TypedRegistrationBase`2.ImplementationType">
<summary>
The <see cref="T:System.Type"/> that implements the <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Registrations.TypedRegistrationBase`2.OnCreateAction">
<summary>
This <see cref="T:System.Action"/> is invoked when an instance of this type is created.
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`1})"/></para>
</summary>
</member>
<member name="M:LightweightIocContainer.Registrations.TypedRegistrationBase`2.OnCreate(System.Action{`1})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.UnitTestCallbackRegistration`1">
<summary>
A special <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> that allows to set a <see cref="T:LightweightIocContainer.ResolveCallback`1"/> as a callback that is called on <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/>

@ -3,19 +3,19 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
/// <summary>
/// The <see cref="DefaultRegistration{TInterface}"/> to register a <see cref="Type"/> for the Interface it implements
/// The <see cref="DefaultRegistration{TInterface,TImplementation}"/> to register a <see cref="Type"/> for the Interface it implements
/// </summary>
/// <typeparam name="TInterface">The <see cref="Type"/> of the interface</typeparam>
public class DefaultRegistration<TInterface> : TypedRegistrationBase<TInterface>, IDefaultRegistration<TInterface>
/// <typeparam name="TImplementation">The <see cref="Type"/>of the implementation</typeparam>
public class DefaultRegistration<TInterface, TImplementation> : TypedRegistrationBase<TInterface, TImplementation>, IDefaultRegistration<TInterface, TImplementation> where TImplementation : TInterface
{
/// <summary>
/// The <see cref="DefaultRegistration{TInterface}"/> to register a <see cref="Type"/> for the Interface it implements
/// The <see cref="DefaultRegistration{TInterface,TImplementation}"/> to register a <see cref="Type"/> for the Interface it implements
/// </summary>
/// <param name="interfaceType">The <see cref="Type"/> of the interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
@ -25,23 +25,5 @@ namespace LightweightIocContainer.Registrations
{
Name = $"{InterfaceType.Name}, {ImplementationType.Name}, Lifestyle: {Lifestyle.ToString()}";
}
/// <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;
}
}
}

@ -9,10 +9,11 @@ using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
/// <summary>
/// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces
/// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2, TImplementation}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
public abstract class MultipleRegistration<TInterface1> : TypedRegistrationBase<TInterface1>, IMultipleRegistration<TInterface1>
/// <typeparam name="TImplementation">The implementation</typeparam>
public abstract class MultipleRegistration<TInterface1, TImplementation> : TypedRegistrationBase<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1
{
/// <summary>
/// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces
@ -37,7 +38,8 @@ namespace LightweightIocContainer.Registrations
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
public class MultipleRegistration<TInterface1, TInterface2> : MultipleRegistration<TInterface1>, IMultipleRegistration<TInterface1, TInterface2>
/// <typeparam name="TImplementation">The implementation</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
@ -51,25 +53,24 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List<IRegistration>()
{
new DefaultRegistration<TInterface1>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2>(interfaceType2, implementationType, lifestyle)
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle)
};
}
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2)
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface2> interface2Registration)
interface2Registration.OnCreate(action2);
else if (registration is IDefaultRegistration<TInterface1> interface1Registration)
interface1Registration.OnCreate(action1);
if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}
return this;
@ -82,7 +83,8 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3> : MultipleRegistration<TInterface1>, IMultipleRegistration<TInterface1, TInterface2, TInterface3>
/// <typeparam name="TImplementation">The implementation</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> where TImplementation : TInterface3, TInterface2, TInterface1
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
@ -97,29 +99,27 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List<IRegistration>()
{
new DefaultRegistration<TInterface1>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3>(interfaceType3, implementationType, lifestyle)
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle)
};
}
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <param name="action3">The third <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2, Action<TInterface3> action3)
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface3> interface3Registration)
interface3Registration.OnCreate(action3);
else if (registration is IDefaultRegistration<TInterface2> interface2Registration)
interface2Registration.OnCreate(action2);
else if (registration is IDefaultRegistration<TInterface1> interface1Registration)
interface1Registration.OnCreate(action1);
if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}
return this;
@ -133,7 +133,8 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> : MultipleRegistration<TInterface1>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4>
/// <typeparam name="TImplementation">The implementation</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
@ -149,33 +150,30 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List<IRegistration>()
{
new DefaultRegistration<TInterface1>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3>(interfaceType3, implementationType, lifestyle),
new DefaultRegistration<TInterface4>(interfaceType4, implementationType, lifestyle)
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle),
new DefaultRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle)
};
}
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <param name="action3">The third <see cref="Action{T}"/></param>
/// <param name="action4">The fourth <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2, Action<TInterface3> action3, Action<TInterface4> action4)
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface4> interface4Registration)
interface4Registration.OnCreate(action4);
else if (registration is IDefaultRegistration<TInterface3> interface3Registration)
interface3Registration.OnCreate(action3);
else if (registration is IDefaultRegistration<TInterface2> interface2Registration)
interface2Registration.OnCreate(action2);
else if (registration is IDefaultRegistration<TInterface1> interface1Registration)
interface1Registration.OnCreate(action1);
if (registration is IDefaultRegistration<TInterface4, TImplementation> interface4Registration)
interface4Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}
return this;
@ -190,7 +188,8 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam>
/// <typeparam name="TInterface5">The fifth interface</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> : MultipleRegistration<TInterface1>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5>
/// <typeparam name="TImplementation">The implementation</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
@ -207,37 +206,33 @@ namespace LightweightIocContainer.Registrations
{
Registrations = new List<IRegistration>()
{
new DefaultRegistration<TInterface1>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3>(interfaceType3, implementationType, lifestyle),
new DefaultRegistration<TInterface4>(interfaceType4, implementationType, lifestyle),
new DefaultRegistration<TInterface5>(interfaceType5, implementationType, lifestyle)
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle),
new DefaultRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle),
new DefaultRegistration<TInterface5, TImplementation>(interfaceType5, implementationType, lifestyle)
};
}
/// <summary>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary>
/// <param name="action1">The first <see cref="Action{T}"/></param>
/// <param name="action2">The second <see cref="Action{T}"/></param>
/// <param name="action3">The third <see cref="Action{T}"/></param>
/// <param name="action4">The fourth <see cref="Action{T}"/></param>
/// <param name="action5">The fifth <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2, Action<TInterface3> action3, Action<TInterface4> action4, Action<TInterface5> action5)
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface5> interface5Registration)
interface5Registration.OnCreate(action5);
else if (registration is IDefaultRegistration<TInterface4> interface4Registration)
interface4Registration.OnCreate(action4);
else if (registration is IDefaultRegistration<TInterface3> interface3Registration)
interface3Registration.OnCreate(action3);
else if (registration is IDefaultRegistration<TInterface2> interface2Registration)
interface2Registration.OnCreate(action2);
else if (registration is IDefaultRegistration<TInterface1> interface1Registration)
interface1Registration.OnCreate(action1);
if (registration is IDefaultRegistration<TInterface5, TImplementation> interface5Registration)
interface5Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface4, TImplementation> interface4Registration)
interface4Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}
return this;

@ -11,7 +11,8 @@ namespace LightweightIocContainer.Registrations
/// The registration that is used to register a multiton
/// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam>
public class MultitonRegistration<TInterface> : DefaultRegistration<TInterface>, IMultitonRegistration<TInterface>
/// <typeparam name="TImplementation">The registered implementation</typeparam>
public class MultitonRegistration<TInterface, TImplementation> : DefaultRegistration<TInterface, TImplementation>, IMultitonRegistration<TInterface, TImplementation> where TImplementation : TInterface
{
/// <summary>
/// The registration that is used to register a multiton

@ -22,15 +22,15 @@ namespace LightweightIocContainer.Registrations
}
/// <summary>
/// Register an Interface with a Type that implements it and create a <see cref="IDefaultRegistration{TInterface}"/>
/// Register an Interface with a Type that implements it and create a <see cref="IDefaultRegistration{TInterface,TImplementation}"/>
/// </summary>
/// <typeparam name="TInterface">The Interface to register</typeparam>
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IDefaultRegistration{TInterface}"/></param>
/// <returns>A new created <see cref="IDefaultRegistration{TInterface}"/> with the given parameters</returns>
public IDefaultRegistration<TInterface> Register<TInterface, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IDefaultRegistration{TInterface,TImplementation}"/></param>
/// <returns>A new created <see cref="IDefaultRegistration{TInterface,TImplementation}"/> with the given parameters</returns>
public IDefaultRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface
{
return new DefaultRegistration<TInterface>(typeof(TInterface), typeof(TImplementation), lifestyle);
return new DefaultRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), lifestyle);
}
/// <summary>
@ -41,9 +41,9 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2
public IMultipleRegistration<TInterface1, TInterface2, TImplementation> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2
{
return new MultipleRegistration<TInterface1, TInterface2>(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle);
return new MultipleRegistration<TInterface1, TInterface2, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle);
}
/// <summary>
@ -55,9 +55,9 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3> Register<TInterface1, TInterface2, TInterface3, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> Register<TInterface1, TInterface2, TInterface3, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3
{
return new MultipleRegistration<TInterface1, TInterface2, TInterface3>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle);
return new MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle);
}
/// <summary>
@ -70,9 +70,9 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4
{
return new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle);
return new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle);
}
/// <summary>
@ -86,9 +86,9 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5
{
return new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle);
return new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle);
}
/// <summary>
@ -103,15 +103,15 @@ namespace LightweightIocContainer.Registrations
}
/// <summary>
/// Register an Interface with a Type that implements it as a multiton and create a <see cref="IMultitonRegistration{TInterface}"/>
/// Register an Interface with a Type that implements it as a multiton and create a <see cref="IMultitonRegistration{TInterface,TImplementation}"/>
/// </summary>
/// <typeparam name="TInterface">The Interface to register</typeparam>
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <typeparam name="TScope">The Type of the multiton scope</typeparam>
/// <returns>A new created <see cref="IMultitonRegistration{TInterface}"/> with the given parameters</returns>
public IMultitonRegistration<TInterface> RegisterMultiton<TInterface, TImplementation, TScope>() where TImplementation : TInterface
/// <returns>A new created <see cref="IMultitonRegistration{TInterface,TImplementation}"/> with the given parameters</returns>
public IMultitonRegistration<TInterface, TImplementation> RegisterMultiton<TInterface, TImplementation, TScope>() where TImplementation : TInterface
{
return new MultitonRegistration<TInterface>(typeof(TInterface), typeof(TImplementation), typeof(TScope));
return new MultitonRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), typeof(TScope));
}
/// <summary>

@ -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
{
/// <summary>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
/// </summary>
public abstract class TypedRegistrationBase<TInterface> : RegistrationBase<TInterface>, ITypedRegistrationBase<TInterface>
public abstract class TypedRegistrationBase<TInterface, TImplementation> : RegistrationBase<TInterface>, ITypedRegistrationBase<TInterface, TImplementation> where TImplementation : TInterface
{
/// <summary>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
@ -28,5 +30,22 @@ namespace LightweightIocContainer.Registrations
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IRegistrationBase{TInterface}"/>
/// </summary>
public Type ImplementationType { get; }
/// <summary>
/// This <see cref="Action"/> is invoked when an instance of this type is created.
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IOnCreate{TInterface,TImplementation}.OnCreate"/></para>
/// </summary>
public Action<object> OnCreateAction { get; private set; }
/// <summary>
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public virtual ITypedRegistrationBase<TInterface, TImplementation> OnCreate(Action<TImplementation> action)
{
OnCreateAction = a => action((TImplementation) a);
return this;
}
}
}

@ -16,7 +16,6 @@ namespace Test.LightweightIocContainer
private interface IBar
{
void ThrowBar();
}
private interface IFoo
@ -25,17 +24,14 @@ namespace Test.LightweightIocContainer
}
private interface IAnotherBar
{
void ThrowAnotherBar();
}
private interface IAnotherFoo
{
void ThrowAnotherFoo();
}
private interface IAnotherOne
{
void ThrowAnotherOne();
}
private class Foo : IFoo, IBar, IAnotherFoo, IAnotherBar, IAnotherOne
@ -44,26 +40,6 @@ namespace Test.LightweightIocContainer
{
throw new Exception("Foo");
}
public void ThrowBar()
{
throw new Exception("Bar");
}
public void ThrowAnotherFoo()
{
throw new Exception("AnotherFoo");
}
public void ThrowAnotherBar()
{
throw new Exception("AnotherBar");
}
public void ThrowAnotherOne()
{
throw new Exception("AnotherOne");
}
}
#endregion TestClasses
@ -85,67 +61,67 @@ namespace Test.LightweightIocContainer
[Test]
public void TestRegistrationOnCreate2()
{
_container.Register<IBar, IFoo, Foo>().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo());
_container.Register<IBar, IFoo, Foo>().OnCreate(foo => foo.ThrowFoo());
Exception fooException = Assert.Throws<Exception>(() => _container.Resolve<IFoo>());
Assert.AreEqual("Foo", fooException.Message);
Exception barException = Assert.Throws<Exception>(() => _container.Resolve<IBar>());
Assert.AreEqual("Bar", barException.Message);
Assert.AreEqual("Foo", barException.Message);
}
[Test]
public void TestRegistrationOnCreate3()
{
_container.Register<IBar, IFoo, IAnotherFoo, Foo>().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo(), anotherFoo => anotherFoo.ThrowAnotherFoo());
_container.Register<IBar, IFoo, IAnotherFoo, Foo>().OnCreate(foo => foo.ThrowFoo());
Exception fooException = Assert.Throws<Exception>(() => _container.Resolve<IFoo>());
Assert.AreEqual("Foo", fooException.Message);
Exception barException = Assert.Throws<Exception>(() => _container.Resolve<IBar>());
Assert.AreEqual("Bar", barException.Message);
Assert.AreEqual("Foo", barException.Message);
Exception anotherFooException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherFoo>());
Assert.AreEqual("AnotherFoo", anotherFooException.Message);
Assert.AreEqual("Foo", anotherFooException.Message);
}
[Test]
public void TestRegistrationOnCreate4()
{
_container.Register<IBar, IFoo, IAnotherFoo, IAnotherBar, Foo>().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo(), anotherFoo => anotherFoo.ThrowAnotherFoo(), anotherBar => anotherBar.ThrowAnotherBar());
_container.Register<IBar, IFoo, IAnotherFoo, IAnotherBar, Foo>().OnCreate(foo => foo.ThrowFoo());
Exception fooException = Assert.Throws<Exception>(() => _container.Resolve<IFoo>());
Assert.AreEqual("Foo", fooException.Message);
Exception barException = Assert.Throws<Exception>(() => _container.Resolve<IBar>());
Assert.AreEqual("Bar", barException.Message);
Assert.AreEqual("Foo", barException.Message);
Exception anotherFooException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherFoo>());
Assert.AreEqual("AnotherFoo", anotherFooException.Message);
Assert.AreEqual("Foo", anotherFooException.Message);
Exception anotherBarException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherBar>());
Assert.AreEqual("AnotherBar", anotherBarException.Message);
Assert.AreEqual("Foo", anotherBarException.Message);
}
[Test]
public void TestRegistrationOnCreate5()
{
_container.Register<IBar, IFoo, IAnotherFoo, IAnotherBar, IAnotherOne, Foo>().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo(), anotherFoo => anotherFoo.ThrowAnotherFoo(), anotherBar => anotherBar.ThrowAnotherBar(), anotherOne => anotherOne.ThrowAnotherOne());
_container.Register<IBar, IFoo, IAnotherFoo, IAnotherBar, IAnotherOne, Foo>().OnCreate(foo => foo.ThrowFoo());
Exception fooException = Assert.Throws<Exception>(() => _container.Resolve<IFoo>());
Assert.AreEqual("Foo", fooException.Message);
Exception barException = Assert.Throws<Exception>(() => _container.Resolve<IBar>());
Assert.AreEqual("Bar", barException.Message);
Assert.AreEqual("Foo", barException.Message);
Exception anotherFooException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherFoo>());
Assert.AreEqual("AnotherFoo", anotherFooException.Message);
Assert.AreEqual("Foo", anotherFooException.Message);
Exception anotherBarException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherBar>());
Assert.AreEqual("AnotherBar", anotherBarException.Message);
Assert.AreEqual("Foo", anotherBarException.Message);
Exception anotherOneException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherOne>());
Assert.AreEqual("AnotherOne", anotherOneException.Message);
Assert.AreEqual("Foo", anotherOneException.Message);
}
[Test]

@ -3,7 +3,6 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using JetBrains.Annotations;
using LightweightIocContainer;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations;
@ -23,16 +22,6 @@ namespace Test.LightweightIocContainer
void DoSomething();
}
private interface IFoo
{
}
private interface IBar
{
}
private class Test : ITest
{
public void DoSomething()
@ -41,27 +30,13 @@ namespace Test.LightweightIocContainer
}
}
[UsedImplicitly]
private class Foo : IFoo
{
public Foo(IBar bar, ITest test)
{
}
}
private class Bar : IBar
{
}
#endregion
[Test]
public void TestOnCreate()
{
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object);
IDefaultRegistration<ITest> testRegistration = (IDefaultRegistration<ITest>) registrationFactory.Register<ITest, Test>(Lifestyle.Transient).OnCreate(t => t.DoSomething());
ITypedRegistrationBase<ITest, Test> testRegistration = registrationFactory.Register<ITest, Test>(Lifestyle.Transient).OnCreate(t => t.DoSomething());
Test test = new Test();

Loading…
Cancel
Save