#33: add multipleRegistrations for up to five interfaces

pull/37/head
Simon Gockner 6 years ago
parent 325320c8a2
commit 24319abb46
  1. 36
      LightweightIocContainer/Interfaces/IIocContainer.cs
  2. 60
      LightweightIocContainer/Interfaces/Registrations/FluentProviders/IOnCreate.cs
  3. 53
      LightweightIocContainer/Interfaces/Registrations/IMultipleRegistration.cs
  4. 74
      LightweightIocContainer/IocContainer.cs
  5. 319
      LightweightIocContainer/LightweightIocContainer.xml
  6. 199
      LightweightIocContainer/Registrations/MultipleRegistration.cs
  7. 45
      LightweightIocContainer/Registrations/RegistrationFactory.cs
  8. 111
      Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs

@ -39,6 +39,42 @@ namespace LightweightIocContainer.Interfaces
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
IMultipleRegistration<TInterface1, TInterface2> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1;
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <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;
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <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;
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TInterface5">A fifth interface to register</typeparam>
/// <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;
/// <summary>
/// Register a <see cref="Type"/> without an interface
/// </summary>

@ -42,4 +42,64 @@ namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
/// <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
/// </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);
}
/// <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>
/// <typeparam name="TInterface5">The fifth registered interface</typeparam>
public interface IOnCreate<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5>
{
/// <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>
/// <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);
}
}

@ -8,15 +8,60 @@ using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
/// The base interface for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2> : ITypedRegistrationBase<TInterface1>, IOnCreate<TInterface1, TInterface2>
public interface IMultipleRegistration<TInterface1> : ITypedRegistrationBase<TInterface1>
{
/// <summary>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1,TInterface2}"/>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1}"/>
/// </summary>
List<IRegistration> Registrations { get; }
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
/// </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>
{
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> 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>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3> : IMultipleRegistration<TInterface1>, IOnCreate<TInterface1, TInterface2, TInterface3>
{
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> 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="TInterface4">The fourth interface</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> : IMultipleRegistration<TInterface1>, IOnCreate<TInterface1, TInterface2, TInterface3, TInterface4>
{
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> 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="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>
{
}
}

@ -79,11 +79,64 @@ namespace LightweightIocContainer
public IMultipleRegistration<TInterface1, TInterface2> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1
{
IMultipleRegistration<TInterface1, TInterface2> multipleRegistration = _registrationFactory.Register<TInterface1, TInterface2, TImplementation>(lifestyle);
Register(multipleRegistration);
foreach (var registration in multipleRegistration.Registrations)
{
Register(registration);
}
return multipleRegistration;
}
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <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
{
IMultipleRegistration<TInterface1, TInterface2, TInterface3> multipleRegistration =
_registrationFactory.Register<TInterface1, TInterface2, TInterface3, TImplementation>(lifestyle);
Register(multipleRegistration);
return multipleRegistration;
}
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <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
{
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> multipleRegistration =
_registrationFactory.Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(lifestyle);
Register(multipleRegistration);
return multipleRegistration;
}
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TInterface5">A fifth interface to register</typeparam>
/// <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
{
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5> multipleRegistration =
_registrationFactory.Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(lifestyle);
Register(multipleRegistration);
return multipleRegistration;
}
@ -159,6 +212,19 @@ namespace LightweightIocContainer
_registrations.Add(registration);
}
/// <summary>
/// Register all <see cref="IMultipleRegistration{TInterface1}.Registrations"/> from an <see cref="IMultipleRegistration{TInterface1}"/>
/// </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)
{
foreach (var registration in multipleRegistration.Registrations)
{
Register(registration);
}
}
/// <summary>
/// Gets an instance of the given <see cref="Type"/>
/// </summary>

@ -356,6 +356,42 @@
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``4(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``5(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``6(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``1(LightweightIocContainer.Lifestyle)">
<summary>
Register a <see cref="T:System.Type"/> without an interface
@ -471,6 +507,63 @@
<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>
</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})">
<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>
<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>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1">
<summary>
Provides a <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.WithParameters(System.Object[])"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
@ -507,6 +600,17 @@
</summary>
<typeparam name="TInterface">The <see cref="T:System.Type"/> of the interface</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1">
<summary>
The base interface for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/> to register multiple interfaces
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1.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"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
@ -514,10 +618,32 @@
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2.Registrations">
<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="TInterface3">The third interface</typeparam>
</member>
<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="TInterface4">The fourth interface</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5">
<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`2"/>
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="TInterface4">The fourth interface</typeparam>
<typeparam name="TInterface5">The fifth interface</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1">
<summary>
@ -647,6 +773,42 @@
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``4(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``5(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``6(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``1(LightweightIocContainer.Lifestyle)">
<summary>
Register a <see cref="T:System.Type"/> without an interface
@ -686,6 +848,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})">
<summary>
Register all <see cref="P:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1.Registrations"/> from an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`1"/>
</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>
</member>
<member name="M:LightweightIocContainer.IocContainer.Resolve``1">
<summary>
Gets an instance of the given <see cref="T:System.Type"/>
@ -838,6 +1007,25 @@
<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">
<summary>
The base class for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/> to register multiple interfaces
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`1.#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>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first 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 this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.MultipleRegistration`1.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">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
@ -854,17 +1042,102 @@
<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`2.Registrations">
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`2.OnCreate(System.Action{`0},System.Action{`1})">
<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"/>
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.Registrations.MultipleRegistration`2"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`2.OnCreate(System.Action{`0},System.Action{`1})">
<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="TInterface3">The third interface</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.#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>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param>
<param name="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
<param name="interfaceType3">The <see cref="T:System.Type"/> of the third 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 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})">
<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.Registrations.MultipleRegistration`2"/></returns>
</member>
<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="TInterface4">The fourth interface</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.#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>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param>
<param name="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
<param name="interfaceType3">The <see cref="T:System.Type"/> of the third interface</param>
<param name="interfaceType4">The <see cref="T:System.Type"/> of the fourth 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 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})">
<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.Registrations.MultipleRegistration`2"/></returns>
</member>
<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>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TInterface4">The fourth interface</typeparam>
<typeparam name="TInterface5">The fifth interface</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.#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>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param>
<param name="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
<param name="interfaceType3">The <see cref="T:System.Type"/> of the third interface</param>
<param name="interfaceType4">The <see cref="T:System.Type"/> of the fourth interface</param>
<param name="interfaceType5">The <see cref="T:System.Type"/> of the fifth 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 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})">
<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>
<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>
</member>
<member name="T:LightweightIocContainer.Registrations.MultitonRegistration`1">
@ -962,6 +1235,42 @@
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``4(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/>
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``5(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/>
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``6(LightweightIocContainer.Lifestyle)">
<summary>
Register multiple interfaces for a <see cref="T:System.Type"/> that implements them and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/>
</summary>
<typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``1(LightweightIocContainer.Lifestyle)">
<summary>
Register a <see cref="T:System.Type"/> without an interface and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1"/>

@ -8,12 +8,36 @@ using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
/// <summary>
/// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
public abstract class MultipleRegistration<TInterface1> : TypedRegistrationBase<TInterface1>, IMultipleRegistration<TInterface1>
{
/// <summary>
/// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces
/// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
protected MultipleRegistration(Type interfaceType1, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
{
}
/// <summary>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="MultipleRegistration{TInterface1,TInterface2}"/>
/// </summary>
public List<IRegistration> Registrations { get; protected set; }
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
public class MultipleRegistration<TInterface1, TInterface2> : TypedRegistrationBase<TInterface1>, IMultipleRegistration<TInterface1, TInterface2>
public class MultipleRegistration<TInterface1, TInterface2> : MultipleRegistration<TInterface1>, IMultipleRegistration<TInterface1, TInterface2>
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
@ -24,30 +48,193 @@ namespace LightweightIocContainer.Registrations
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
{
Registrations = new List<IRegistration>()
{
new DefaultRegistration<TInterface1>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2>(interfaceType2, implementationType, lifestyle)
};
}
/// <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="MultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface2> interface2Registration)
interface2Registration.OnCreate(action2);
else if (registration is IDefaultRegistration<TInterface1> interface1Registration)
interface1Registration.OnCreate(action1);
}
return this;
}
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> 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>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3> : MultipleRegistration<TInterface1>, IMultipleRegistration<TInterface1, TInterface2, TInterface3>
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
/// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param>
/// <param name="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="interfaceType3">The <see cref="Type"/> of the third interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
{
Registrations = new List<IRegistration>()
{
new DefaultRegistration<TInterface1>(interfaceType1, implementationType, lifestyle),
new DefaultRegistration<TInterface2>(interfaceType2, implementationType, lifestyle)
new DefaultRegistration<TInterface2>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3>(interfaceType3, implementationType, lifestyle)
};
}
/// <summary>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="MultipleRegistration{TInterface1,TInterface2}"/>
/// Pass an <see cref="Action{T}"/> for each interface that will be invoked when instances of the types are created
/// </summary>
public List<IRegistration> Registrations { get; }
/// <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)
{
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);
}
return this;
}
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> 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="TInterface4">The fourth interface</typeparam>
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> : MultipleRegistration<TInterface1>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4>
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
/// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param>
/// <param name="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="interfaceType3">The <see cref="Type"/> of the third interface</param>
/// <param name="interfaceType4">The <see cref="Type"/> of the fourth interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type interfaceType4, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
{
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)
};
}
/// <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>
/// <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> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2)
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4> OnCreate(Action<TInterface1> action1, Action<TInterface2> action2, Action<TInterface3> action3, Action<TInterface4> action4)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface2> interface2Registration)
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);
}
return this;
}
}
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> 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="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>
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type
/// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param>
/// <param name="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="interfaceType3">The <see cref="Type"/> of the third interface</param>
/// <param name="interfaceType4">The <see cref="Type"/> of the fourth interface</param>
/// <param name="interfaceType5">The <see cref="Type"/> of the fifth interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type interfaceType4, Type interfaceType5, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
{
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)
};
}
/// <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>
/// <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)
{
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);

@ -46,6 +46,51 @@ namespace LightweightIocContainer.Registrations
return new MultipleRegistration<TInterface1, TInterface2>(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle);
}
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/>
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <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
{
return new MultipleRegistration<TInterface1, TInterface2, TInterface3>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle);
}
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/>
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <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
{
return new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle);
}
/// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/>
/// </summary>
/// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TInterface5">A fifth interface to register</typeparam>
/// <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
{
return new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle);
}
/// <summary>
/// Register a <see cref="Type"/> without an interface and create a <see cref="ISingleTypeRegistration{TInterface}"/>
/// </summary>

@ -23,8 +23,22 @@ namespace Test.LightweightIocContainer
{
void ThrowFoo();
}
private interface IAnotherBar
{
void ThrowAnotherBar();
}
private interface IAnotherFoo
{
void ThrowAnotherFoo();
}
private interface IAnotherOne
{
void ThrowAnotherOne();
}
private class Foo : IFoo, IBar
private class Foo : IFoo, IBar, IAnotherFoo, IAnotherBar, IAnotherOne
{
public void ThrowFoo()
{
@ -35,6 +49,21 @@ namespace Test.LightweightIocContainer
{
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
@ -54,7 +83,7 @@ namespace Test.LightweightIocContainer
}
[Test]
public void TestRegistrationOnCreate()
public void TestRegistrationOnCreate2()
{
_container.Register<IBar, IFoo, Foo>().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo());
@ -65,28 +94,102 @@ namespace Test.LightweightIocContainer
Assert.AreEqual("Bar", barException.Message);
}
[Test]
public void TestRegistrationOnCreate3()
{
_container.Register<IBar, IFoo, IAnotherFoo, Foo>().OnCreate(bar => bar.ThrowBar(), foo => foo.ThrowFoo(), anotherFoo => anotherFoo.ThrowAnotherFoo());
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);
Exception anotherFooException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherFoo>());
Assert.AreEqual("AnotherFoo", 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());
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);
Exception anotherFooException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherFoo>());
Assert.AreEqual("AnotherFoo", anotherFooException.Message);
Exception anotherBarException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherBar>());
Assert.AreEqual("AnotherBar", 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());
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);
Exception anotherFooException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherFoo>());
Assert.AreEqual("AnotherFoo", anotherFooException.Message);
Exception anotherBarException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherBar>());
Assert.AreEqual("AnotherBar", anotherBarException.Message);
Exception anotherOneException = Assert.Throws<Exception>(() => _container.Resolve<IAnotherOne>());
Assert.AreEqual("AnotherOne", anotherOneException.Message);
}
[Test]
public void TestResolveTransient()
{
_container.Register<IBar, IFoo, Foo>();
_container.Register<IBar, IFoo, IAnotherFoo, IAnotherBar, IAnotherOne, Foo>();
IFoo foo = _container.Resolve<IFoo>();
IBar bar = _container.Resolve<IBar>();
IAnotherFoo anotherFoo = _container.Resolve<IAnotherFoo>();
IAnotherBar anotherBar = _container.Resolve<IAnotherBar>();
IAnotherOne anotherOne = _container.Resolve<IAnotherOne>();
Assert.IsInstanceOf<Foo>(foo);
Assert.IsInstanceOf<Foo>(bar);
Assert.IsInstanceOf<Foo>(anotherFoo);
Assert.IsInstanceOf<Foo>(anotherBar);
Assert.IsInstanceOf<Foo>(anotherOne);
}
[Test]
public void TestResolveSingleton()
{
_container.Register<IBar, IFoo, Foo>(Lifestyle.Singleton);
_container.Register<IBar, IFoo, IAnotherFoo, IAnotherBar, IAnotherOne, Foo>(Lifestyle.Singleton);
IFoo foo = _container.Resolve<IFoo>();
IBar bar = _container.Resolve<IBar>();
IAnotherFoo anotherFoo = _container.Resolve<IAnotherFoo>();
IAnotherBar anotherBar = _container.Resolve<IAnotherBar>();
IAnotherOne anotherOne = _container.Resolve<IAnotherOne>();
Assert.IsInstanceOf<Foo>(foo);
Assert.IsInstanceOf<Foo>(bar);
Assert.IsInstanceOf<Foo>(anotherFoo);
Assert.IsInstanceOf<Foo>(anotherBar);
Assert.IsInstanceOf<Foo>(anotherOne);
Assert.AreEqual(foo, bar);
Assert.AreEqual(foo, anotherFoo);
Assert.AreEqual(foo, anotherBar);
Assert.AreEqual(foo, anotherOne);
Assert.AreSame(foo, bar);
Assert.AreSame(foo, anotherFoo);
Assert.AreSame(foo, anotherBar);
Assert.AreSame(foo, anotherOne);
}
}
}
Loading…
Cancel
Save