#50: append factory registration

- add withFactory fluent interface
- remove unneeded DefaultRegistration
pull/53/head
Simon G 4 years ago
parent 9e957dac5a
commit b18c0dc858
  1. 13
      LightweightIocContainer/Factories/CustomTypedFactory.cs
  2. 127
      LightweightIocContainer/Factories/TypedFactory.cs
  3. 7
      LightweightIocContainer/Interfaces/Factories/ITypedFactory.cs
  4. 26
      LightweightIocContainer/Interfaces/IIocContainer.cs
  5. 6
      LightweightIocContainer/Interfaces/Registrations/Fluent/IOnCreate.cs
  6. 16
      LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs
  7. 11
      LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs
  8. 18
      LightweightIocContainer/Interfaces/Registrations/IDefaultRegistration.cs
  9. 2
      LightweightIocContainer/Interfaces/Registrations/IMultipleMultitonRegistration.cs
  10. 10
      LightweightIocContainer/Interfaces/Registrations/IMultipleRegistration.cs
  11. 14
      LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
  12. 9
      LightweightIocContainer/Interfaces/Registrations/IOpenGenericRegistration.cs
  13. 5
      LightweightIocContainer/Interfaces/Registrations/IRegistration.cs
  14. 16
      LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs
  15. 8
      LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs
  16. 28
      LightweightIocContainer/Interfaces/Registrations/ITypedRegistration.cs
  17. 36
      LightweightIocContainer/Interfaces/Registrations/ITypedRegistrationBase.cs
  18. 63
      LightweightIocContainer/IocContainer.cs
  19. 366
      LightweightIocContainer/LightweightIocContainer.xml
  20. 27
      LightweightIocContainer/Registrations/DefaultRegistration.cs
  21. 14
      LightweightIocContainer/Registrations/MultipleMultitonRegistration.cs
  22. 124
      LightweightIocContainer/Registrations/MultipleRegistration.cs
  23. 8
      LightweightIocContainer/Registrations/MultitonRegistration.cs
  24. 30
      LightweightIocContainer/Registrations/OpenGenericRegistration.cs
  25. 56
      LightweightIocContainer/Registrations/RegistrationBase.cs
  26. 29
      LightweightIocContainer/Registrations/RegistrationFactory.cs
  27. 21
      LightweightIocContainer/Registrations/SingleTypeRegistration.cs
  28. 149
      LightweightIocContainer/Registrations/TypedFactoryRegistration.cs
  29. 14
      LightweightIocContainer/Registrations/TypedRegistration.cs
  30. 230
      Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs
  31. 169
      Test.LightweightIocContainer/IocContainerTest.cs
  32. 4
      Test.LightweightIocContainer/OnCreateTest.cs
  33. 13
      Test.LightweightIocContainer/RegistrationBaseTest.cs
  34. 2
      Test.LightweightIocContainer/SingleTypeRegistrationTest.cs

@ -0,0 +1,13 @@
// Author: Gockner, Simon
// Created: 2021-12-01
// Copyright(c) 2021 SimonG. All Rights Reserved.
using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Factories
{
public class CustomTypedFactory : ITypedFactory
{
}
}

@ -2,6 +2,13 @@
// Created: 2019-05-20 // Created: 2019-05-20
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Factories namespace LightweightIocContainer.Factories
@ -12,9 +19,129 @@ namespace LightweightIocContainer.Factories
/// <typeparam name="TFactory">The type of the abstract factory</typeparam> /// <typeparam name="TFactory">The type of the abstract factory</typeparam>
public class TypedFactory<TFactory> : ITypedFactory<TFactory> public class TypedFactory<TFactory> : ITypedFactory<TFactory>
{ {
private const string CLEAR_MULTITON_INSTANCE_METHOD_NAME = "ClearMultitonInstance";
/// <summary>
/// The
/// </summary>
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
public TypedFactory(IIocContainer container) => CreateFactory(container);
/// <summary> /// <summary>
/// The implemented abstract typed factory/> /// The implemented abstract typed factory/>
/// </summary> /// </summary>
public TFactory Factory { get; set; } public TFactory Factory { get; set; }
/// <summary>
/// Creates the factory from the given abstract factory type
/// </summary>
/// <exception cref="InvalidFactoryRegistrationException">Factory registration is invalid</exception>
/// <exception cref="IllegalAbstractMethodCreationException">Creation of abstract methods are illegal in their current state</exception>
private void CreateFactory(IIocContainer container)
{
Type factoryType = typeof(TFactory);
List<MethodInfo> createMethods = factoryType.GetMethods().Where(m => m.ReturnType != typeof(void)).ToList();
if (!createMethods.Any())
throw new InvalidFactoryRegistrationException($"Factory {factoryType.Name} has no create methods.");
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Factory"), AssemblyBuilderAccess.Run);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Factory");
TypeBuilder typeBuilder = moduleBuilder.DefineType($"TypedFactory.{factoryType.Name}");
typeBuilder.AddInterfaceImplementation(factoryType);
//add `private readonly IIocContainer _container` field
FieldBuilder containerFieldBuilder = typeBuilder.DefineField("_container", typeof(IIocContainer), FieldAttributes.Private | FieldAttributes.InitOnly);
//add ctor
ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.HasThis, new[] {typeof(IIocContainer)});
ILGenerator constructorGenerator = constructorBuilder.GetILGenerator();
constructorGenerator.Emit(OpCodes.Ldarg_0);
constructorGenerator.Emit(OpCodes.Ldarg_1);
constructorGenerator.Emit(OpCodes.Stfld, containerFieldBuilder); //set `_container` field
constructorGenerator.Emit(OpCodes.Ret);
foreach (MethodInfo createMethod in createMethods)
{
//create a method that looks like this
//public `createMethod.ReturnType` Create(`createMethod.GetParameters()`)
//{
// return IIocContainer.Resolve(`createMethod.ReturnType`, params);
//}
ParameterInfo[] args = createMethod.GetParameters();
MethodBuilder methodBuilder = typeBuilder.DefineMethod(createMethod.Name, MethodAttributes.Public | MethodAttributes.Virtual,
createMethod.ReturnType, (from arg in args select arg.ParameterType).ToArray());
typeBuilder.DefineMethodOverride(methodBuilder, createMethod);
ILGenerator generator = methodBuilder.GetILGenerator();
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Ldfld, containerFieldBuilder);
if (args.Any())
{
generator.Emit(OpCodes.Ldc_I4_S, args.Length);
generator.Emit(OpCodes.Newarr, typeof(object));
for (int i = 0; i < args.Length; i++)
{
generator.Emit(OpCodes.Dup);
generator.Emit(OpCodes.Ldc_I4_S, i);
generator.Emit(OpCodes.Ldarg_S, i + 1);
generator.Emit(OpCodes.Box, args[i].ParameterType); //Boxing is only needed for simple datatypes, but for now it is not a problem to box everything
generator.Emit(OpCodes.Stelem_Ref);
}
}
else
{
MethodInfo emptyArray = typeof(Array).GetMethod(nameof(Array.Empty))?.MakeGenericMethod(typeof(object));
generator.EmitCall(OpCodes.Call, emptyArray, null);
}
generator.EmitCall(OpCodes.Callvirt, typeof(IIocContainer).GetMethod(nameof(IIocContainer.Resolve), new[] { typeof(object[]) })?.MakeGenericMethod(createMethod.ReturnType), null);
generator.Emit(OpCodes.Castclass, createMethod.ReturnType);
generator.Emit(OpCodes.Ret);
}
//if factory contains a method to clear multiton instances
MethodInfo multitonClearMethod = factoryType.GetMethods().FirstOrDefault(m => m.Name.Equals(CLEAR_MULTITON_INSTANCE_METHOD_NAME));
if (multitonClearMethod != null)
{
//create a method that looks like this
//public void ClearMultitonInstance<typeToClear>()
//{
// IIocContainer.ClearMultitonInstances<typeToClear>();
//}
if (multitonClearMethod.IsGenericMethod)
{
Type typeToClear = multitonClearMethod.GetGenericArguments().FirstOrDefault();
if (typeToClear == null)
throw new IllegalAbstractMethodCreationException("No Type to clear specified.", multitonClearMethod);
MethodBuilder multitonClearMethodBuilder = typeBuilder.DefineMethod(multitonClearMethod.Name, MethodAttributes.Public | MethodAttributes.Virtual,
multitonClearMethod.ReturnType, null);
multitonClearMethodBuilder.DefineGenericParameters(typeToClear.Name);
typeBuilder.DefineMethodOverride(multitonClearMethodBuilder, multitonClearMethod);
ILGenerator multitonClearGenerator = multitonClearMethodBuilder.GetILGenerator();
multitonClearGenerator.Emit(OpCodes.Ldarg_0);
multitonClearGenerator.Emit(OpCodes.Ldfld, containerFieldBuilder);
multitonClearGenerator.EmitCall(OpCodes.Callvirt, typeof(IIocContainer).GetMethod(nameof(IIocContainer.ClearMultitonInstances))?.MakeGenericMethod(typeToClear), null);
multitonClearGenerator.Emit(OpCodes.Ret);
}
else
{
throw new IllegalAbstractMethodCreationException("No Type to clear specified.", multitonClearMethod);
}
}
Factory = (TFactory) Activator.CreateInstance(typeBuilder.CreateTypeInfo().AsType(), container);
}
} }
} }

@ -4,11 +4,16 @@
namespace LightweightIocContainer.Interfaces.Factories namespace LightweightIocContainer.Interfaces.Factories
{ {
public interface ITypedFactory
{
}
/// <summary> /// <summary>
/// Class to help implement an abstract typed factory /// Class to help implement an abstract typed factory
/// </summary> /// </summary>
/// <typeparam name="TFactory">The type of the abstract factory</typeparam> /// <typeparam name="TFactory">The type of the abstract factory</typeparam>
public interface ITypedFactory<TFactory> public interface ITypedFactory<TFactory> : ITypedFactory
{ {
/// <summary> /// <summary>
/// The implemented abstract typed factory /// The implemented abstract typed factory

@ -25,18 +25,19 @@ namespace LightweightIocContainer.Interfaces
/// </summary> /// </summary>
/// <typeparam name="TInterface">The Interface to register</typeparam> /// <typeparam name="TInterface">The Interface to register</typeparam>
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam> /// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <returns>The created <see cref="IRegistration"/></returns> /// <returns>The created <see cref="IRegistration"/></returns>
IDefaultRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface; ITypedRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface;
/// <summary> /// <summary>
/// Register an open generic Interface with an open generic Type that implements it /// Register an open generic Interface with an open generic Type that implements it
/// </summary> /// </summary>
/// <param name="tInterface">The open generic Interface to register</param> /// <param name="tInterface">The open generic Interface to register</param>
/// <param name="tImplementation">The open generic Type that implements the interface</param> /// <param name="tImplementation">The open generic Type that implements the interface</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IOpenGenericRegistration"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <returns>The created <see cref="IRegistration"/></returns> /// <returns>The created <see cref="IRegistration"/></returns>
IOpenGenericRegistration RegisterOpenGenerics(Type tInterface, Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient); IOpenGenericRegistration RegisterOpenGenerics(Type tInterface, Type tImplementation,
Lifestyle lifestyle = Lifestyle.Transient);
/// <summary> /// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them /// Register multiple interfaces for a <see cref="Type"/> that implements them
@ -44,7 +45,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TInterface1">The base interface to register</typeparam> /// <typeparam name="TInterface1">The base interface to register</typeparam>
/// <typeparam name="TInterface2">A second interface to register</typeparam> /// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</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> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TImplementation> 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;
@ -55,7 +56,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TInterface2">A second interface to register</typeparam> /// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third 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> /// <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> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns>
IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> 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;
@ -67,7 +68,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TInterface3">A third interface to register</typeparam> /// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth 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> /// <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> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/></returns> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/></returns>
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, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1;
@ -80,7 +81,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TInterface4">A fourth interface to register</typeparam> /// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TInterface5">A fifth 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> /// <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> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/></returns> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/></returns>
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, TImplementation> Register<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1;
@ -88,7 +89,7 @@ namespace LightweightIocContainer.Interfaces
/// Register a <see cref="Type"/> without an interface /// Register a <see cref="Type"/> without an interface
/// </summary> /// </summary>
/// <typeparam name="TImplementation">The <see cref="Type"/> to register</typeparam> /// <typeparam name="TImplementation">The <see cref="Type"/> to register</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <returns>The created <see cref="IRegistration"/></returns> /// <returns>The created <see cref="IRegistration"/></returns>
ISingleTypeRegistration<TImplementation> Register<TImplementation>(Lifestyle lifestyle = Lifestyle.Transient); ISingleTypeRegistration<TImplementation> Register<TImplementation>(Lifestyle lifestyle = Lifestyle.Transient);
@ -111,13 +112,6 @@ namespace LightweightIocContainer.Interfaces
/// <returns>The created <see cref="IRegistration"/></returns> /// <returns>The created <see cref="IRegistration"/></returns>
IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> RegisterMultiton<TInterface1, TInterface2, TImplementation, TScope>() where TImplementation : TInterface1, TInterface2; IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> RegisterMultiton<TInterface1, TInterface2, TImplementation, TScope>() where TImplementation : TInterface1, TInterface2;
/// <summary>
/// Register an Interface as an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The abstract typed factory to register</typeparam>
/// <returns>The created <see cref="IRegistration"/></returns>
ITypedFactoryRegistration<TFactory> RegisterFactory<TFactory>();
/// <summary> /// <summary>
/// Gets an instance of the given <see cref="Type"/> /// Gets an instance of the given <see cref="Type"/>
/// </summary> /// </summary>

@ -5,7 +5,7 @@
using System; using System;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders namespace LightweightIocContainer.Interfaces.Registrations.Fluent
{ {
/// <summary> /// <summary>
/// Provides an <see cref="OnCreateAction"/> to the generic <see cref="IOnCreate{TInterface, TImplementation}"/> /// Provides an <see cref="OnCreateAction"/> to the generic <see cref="IOnCreate{TInterface, TImplementation}"/>
@ -30,7 +30,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
ITypedRegistrationBase<TInterface, TImplementation> OnCreate(Action<TImplementation> action); ITypedRegistration<TInterface, TImplementation> OnCreate(Action<TImplementation> action);
} }
} }

@ -0,0 +1,16 @@
// Author: Gockner, Simon
// Created: 2021-11-30
// Copyright(c) 2021 SimonG. All Rights Reserved.
using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Interfaces.Registrations.Fluent
{
public interface IWithFactory
{
ITypedFactory Factory { get; }
IRegistrationBase WithFactory<TFactory>();
IRegistrationBase WithFactory<TFactoryInterface, TFactoryImplementation>() where TFactoryImplementation : TFactoryInterface;
}
}

@ -6,13 +6,12 @@ using System;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders namespace LightweightIocContainer.Interfaces.Registrations.Fluent
{ {
/// <summary> /// <summary>
/// Provides a <see cref="WithParameters(object[])"/> method to an <see cref="IRegistrationBase{TInterface}"/> /// Provides a <see cref="WithParameters(object[])"/> method to an <see cref="IRegistration"/>
/// </summary> /// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam> public interface IWithParameters
public interface IWithParameters<TInterface>
{ {
/// <summary> /// <summary>
/// An <see cref="Array"/> of parameters that are used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// An <see cref="Array"/> of parameters that are used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
@ -27,7 +26,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
/// <param name="parameters">The parameters</param> /// <param name="parameters">The parameters</param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns>
/// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception> /// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception>
IRegistrationBase<TInterface> WithParameters(params object[] parameters); IRegistrationBase WithParameters(params object[] parameters);
/// <summary> /// <summary>
/// Pass parameters that will be used to<see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// Pass parameters that will be used to<see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
@ -36,6 +35,6 @@ namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
/// <param name="parameters">The parameters with their position</param> /// <param name="parameters">The parameters with their position</param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns>
/// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception> /// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception>
IRegistrationBase<TInterface> WithParameters(params (int index, object parameter)[] parameters); IRegistrationBase WithParameters(params (int index, object parameter)[] parameters);
} }
} }

@ -1,18 +0,0 @@
// Author: Gockner, Simon
// Created: 2019-11-22
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// 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>
/// <typeparam name="TImplementation">The <see cref="Type"/> of the implementation</typeparam>
public interface IDefaultRegistration<TInterface, TImplementation> : ITypedRegistrationBase<TInterface, TImplementation> where TImplementation : TInterface
{
}
}

@ -5,7 +5,7 @@
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type that implements them as a multiton /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type that implements them as a multiton
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>

@ -11,7 +11,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TImplementation> : ITypedRegistrationBase<TInterface1, TImplementation> where TImplementation : TInterface1 public interface IMultipleRegistration<TInterface1, TImplementation> : ITypedRegistration<TInterface1, TImplementation> where TImplementation : TInterface1
{ {
/// <summary> /// <summary>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1,TImplementation}"/> /// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1,TImplementation}"/>
@ -20,7 +20,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
@ -31,7 +31,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
@ -43,7 +43,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
@ -56,7 +56,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>

@ -7,17 +7,9 @@ using System;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations
{ {
/// <summary> /// <summary>
/// Non generic <see cref="IMultitonRegistration{TInterface}"/> /// Non generic <see cref="IMultipleRegistration{TInterface1,TImplementation}"/>
/// </summary> /// </summary>
public interface IMultitonRegistration public interface IMultitonRegistration : ITypedRegistration
{
}
/// <summary>
/// A base <see cref="IMultitonRegistration{TInterface}"/> without implementation
/// </summary>
public interface IMultitonRegistration<TInterface> : ITypedRegistrationBase<TInterface>, IMultitonRegistration
{ {
/// <summary> /// <summary>
/// The <see cref="Type"/> of the multiton scope /// The <see cref="Type"/> of the multiton scope
@ -30,7 +22,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// </summary> /// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam> /// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam> /// <typeparam name="TImplementation">The registered implementation</typeparam>
public interface IMultitonRegistration<TInterface, TImplementation> : IMultitonRegistration<TInterface>, IDefaultRegistration<TInterface, TImplementation> where TImplementation : TInterface public interface IMultitonRegistration<TInterface, TImplementation> : IMultitonRegistration, ITypedRegistration<TInterface, TImplementation> where TImplementation : TInterface
{ {
} }

@ -2,18 +2,13 @@
// Created: 2020-09-18 // Created: 2020-09-18
// Copyright(c) 2020 SimonG. All Rights Reserved. // Copyright(c) 2020 SimonG. All Rights Reserved.
using System;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations
{ {
/// <summary> /// <summary>
/// <see cref="IRegistration"/> for open generic types /// <see cref="IRegistration"/> for open generic types
/// </summary> /// </summary>
public interface IOpenGenericRegistration : IRegistration, ILifestyleProvider public interface IOpenGenericRegistration : ITypedRegistration
{ {
/// <summary>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IOpenGenericRegistration"/>
/// </summary>
Type ImplementationType { get; }
} }
} }

@ -11,11 +11,6 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// </summary> /// </summary>
public interface IRegistration public interface IRegistration
{ {
/// <summary>
/// The name of the <see cref="IRegistration"/>
/// </summary>
string Name { get; }
/// <summary> /// <summary>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="IRegistration"/> /// The <see cref="Type"/> of the Interface that is registered with this <see cref="IRegistration"/>
/// </summary> /// </summary>

@ -2,23 +2,11 @@
// Created: 2019-05-20 // Created: 2019-05-20
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
using LightweightIocContainer.Interfaces.Registrations.FluentProviders; using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations
{ {
/// <summary> public interface IRegistrationBase : IRegistration, IWithFactory, IWithParameters, ILifestyleProvider
/// A base <see cref="IRegistrationBase"/> without generic interface
/// </summary>
public interface IRegistrationBase : IRegistration, ILifestyleProvider
{
}
/// <summary>
/// The <see cref="IRegistrationBase{TInterface}"/> that is used to register an Interface
/// </summary>
/// <typeparam name="TInterface">The registered Interface</typeparam>
public interface IRegistrationBase<TInterface> : IRegistrationBase, IWithParameters<TInterface>
{ {
} }

@ -7,10 +7,10 @@ using System;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations
{ {
/// <summary> /// <summary>
/// The <see cref="IRegistrationBase{TInterface}"/> to register either only an interface or only a <see cref="Type"/> /// The <see cref="IRegistration"/> to register either only an interface or only a <see cref="Type"/>
/// </summary> /// </summary>
/// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistrationBase{TInterface}"/></typeparam> /// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistration"/></typeparam>
public interface ISingleTypeRegistration<T> : IRegistrationBase<T> public interface ISingleTypeRegistration<T> : IRegistrationBase
{ {
/// <summary> /// <summary>
/// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way /// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way
@ -21,7 +21,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way /// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way
/// </summary> /// </summary>
/// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param> /// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistration"/></returns>
ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocContainer, T> factoryMethod); ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocContainer, T> factoryMethod);
} }
} }

@ -0,0 +1,28 @@
// Author: Simon Gockner
// Created: 2019-12-08
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// A base <see cref="ITypedRegistration"/> without generic interface and implementation
/// </summary>
public interface ITypedRegistration : IRegistrationBase
{
/// <summary>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IRegistration"/>
/// </summary>
Type ImplementationType { get; }
}
/// <summary>
/// A <see cref="IRegistration"/> that implements a <see cref="Type"/>
/// </summary>
public interface ITypedRegistration<TInterface, TImplementation> : ITypedRegistration, IOnCreate<TInterface, TImplementation> where TImplementation : TInterface
{
}
}

@ -1,36 +0,0 @@
// Author: Simon Gockner
// Created: 2019-12-08
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// A base <see cref="ITypedRegistrationBase"/> without generic interface and implementation
/// </summary>
public interface ITypedRegistrationBase : IRegistrationBase
{
/// <summary>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IRegistrationBase{TInterface}"/>
/// </summary>
Type ImplementationType { get; }
}
/// <summary>
/// A base <see cref="ITypedRegistrationBase{TInterface}"/> without generic implementation
/// </summary>
public interface ITypedRegistrationBase<TInterface> : IRegistrationBase<TInterface>, ITypedRegistrationBase
{
}
/// <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
{
}
}

@ -10,9 +10,10 @@ using System.Runtime.CompilerServices;
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders; using LightweightIocContainer.Interfaces.Registrations.Fluent;
using LightweightIocContainer.Registrations; using LightweightIocContainer.Registrations;
namespace LightweightIocContainer namespace LightweightIocContainer
@ -56,9 +57,9 @@ namespace LightweightIocContainer
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam> /// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IRegistration"/></returns> /// <returns>The created <see cref="IRegistration"/></returns>
public IDefaultRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface public ITypedRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface
{ {
IDefaultRegistration<TInterface, TImplementation> registration = _registrationFactory.Register<TInterface, TImplementation>(lifestyle); ITypedRegistration<TInterface, TImplementation> registration = _registrationFactory.Register<TInterface, TImplementation>(lifestyle);
Register(registration); Register(registration);
return registration; return registration;
@ -210,13 +211,7 @@ namespace LightweightIocContainer
/// </summary> /// </summary>
/// <typeparam name="TFactory">The abstract typed factory to register</typeparam> /// <typeparam name="TFactory">The abstract typed factory to register</typeparam>
/// <returns>The created <see cref="IRegistration"/></returns> /// <returns>The created <see cref="IRegistration"/></returns>
public ITypedFactoryRegistration<TFactory> RegisterFactory<TFactory>() internal void RegisterFactory<TFactory>(ITypedFactory<TFactory> factory) => Register(_registrationFactory.RegisterFactory(factory));
{
ITypedFactoryRegistration<TFactory> registration = _registrationFactory.RegisterFactory<TFactory>();
Register(registration);
return registration;
}
/// <summary> /// <summary>
/// Add the <see cref="IRegistration"/> to the the <see cref="IocContainer"/> /// Add the <see cref="IRegistration"/> to the the <see cref="IocContainer"/>
@ -255,7 +250,7 @@ namespace LightweightIocContainer
/// </summary> /// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam> /// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <returns>An instance of the given <see cref="Type"/></returns> /// <returns>An instance of the given <see cref="Type"/></returns>
public T Resolve<T>() => ResolveInternal<T>(null); public virtual T Resolve<T>() => ResolveInternal<T>(null);
/// <summary> /// <summary>
/// Gets an instance of the given <see cref="Type"/> /// Gets an instance of the given <see cref="Type"/>
@ -305,8 +300,8 @@ namespace LightweightIocContainer
{ {
if (defaultRegistration.Lifestyle == Lifestyle.Singleton) if (defaultRegistration.Lifestyle == Lifestyle.Singleton)
resolvedInstance = GetOrCreateSingletonInstance<T>(defaultRegistration, arguments, resolveStack); resolvedInstance = GetOrCreateSingletonInstance<T>(defaultRegistration, arguments, resolveStack);
else if (defaultRegistration is IMultitonRegistration<T> multitonRegistration && defaultRegistration.Lifestyle == Lifestyle.Multiton) else if (defaultRegistration is IMultitonRegistration multitonRegistration && defaultRegistration.Lifestyle == Lifestyle.Multiton)
resolvedInstance = GetOrCreateMultitonInstance(multitonRegistration, arguments, resolveStack); resolvedInstance = GetOrCreateMultitonInstance<T>(multitonRegistration, arguments, resolveStack);
else else
resolvedInstance = CreateInstance<T>(defaultRegistration, arguments, resolveStack); resolvedInstance = CreateInstance<T>(defaultRegistration, arguments, resolveStack);
} }
@ -314,13 +309,6 @@ namespace LightweightIocContainer
{ {
resolvedInstance = typedFactoryRegistration.Factory.Factory; resolvedInstance = typedFactoryRegistration.Factory.Factory;
} }
else if (registration is IOpenGenericRegistration openGenericRegistration)
{
if (openGenericRegistration.Lifestyle == Lifestyle.Singleton)
resolvedInstance = GetOrCreateSingletonInstance<T>(openGenericRegistration, arguments, resolveStack);
else
resolvedInstance = CreateInstance<T>(openGenericRegistration, arguments, resolveStack);
}
else else
throw new UnknownRegistrationException($"There is no registration of type {registration.GetType().Name}."); throw new UnknownRegistrationException($"There is no registration of type {registration.GetType().Name}.");
@ -340,12 +328,10 @@ namespace LightweightIocContainer
private T GetOrCreateSingletonInstance<T>(IRegistration registration, object[] arguments, List<Type> resolveStack) private T GetOrCreateSingletonInstance<T>(IRegistration registration, object[] arguments, List<Type> resolveStack)
{ {
Type type; Type type;
if (registration is ITypedRegistrationBase<T> typedRegistration) if (registration is ITypedRegistration typedRegistration)
type = typedRegistration.ImplementationType; type = typedRegistration.ImplementationType;
else if (registration is ISingleTypeRegistration<T> singleTypeRegistration) else if (registration is ISingleTypeRegistration<T> singleTypeRegistration)
type = singleTypeRegistration.InterfaceType; type = singleTypeRegistration.InterfaceType;
else if (registration is IOpenGenericRegistration openGenericRegistration)
type = openGenericRegistration.ImplementationType;
else else
throw new UnknownRegistrationException($"There is no registration {registration.GetType().Name} that can have lifestyle singleton."); throw new UnknownRegistrationException($"There is no registration {registration.GetType().Name} that can have lifestyle singleton.");
@ -371,7 +357,7 @@ namespace LightweightIocContainer
/// <returns>An existing or newly created multiton instance of the given <see cref="Type"/></returns> /// <returns>An existing or newly created multiton instance of the given <see cref="Type"/></returns>
/// <exception cref="MultitonResolveException">No arguments given</exception> /// <exception cref="MultitonResolveException">No arguments given</exception>
/// <exception cref="MultitonResolveException">Scope argument not given</exception> /// <exception cref="MultitonResolveException">Scope argument not given</exception>
private T GetOrCreateMultitonInstance<T>(IMultitonRegistration<T> registration, object[] arguments, List<Type> resolveStack) private T GetOrCreateMultitonInstance<T>(IMultitonRegistration registration, object[] arguments, List<Type> resolveStack)
{ {
if (arguments == null || !arguments.Any()) if (arguments == null || !arguments.Any())
throw new MultitonResolveException("Can not resolve multiton without arguments.", typeof(T)); throw new MultitonResolveException("Can not resolve multiton without arguments.", typeof(T));
@ -413,11 +399,20 @@ namespace LightweightIocContainer
/// <returns>A newly created instance of the given <see cref="Type"/></returns> /// <returns>A newly created instance of the given <see cref="Type"/></returns>
private T CreateInstance<T>(IRegistration registration, object[] arguments, List<Type> resolveStack) private T CreateInstance<T>(IRegistration registration, object[] arguments, List<Type> resolveStack)
{ {
if (registration is IWithParameters<T> { Parameters: { } } registrationWithParameters) if (registration is IWithParameters { Parameters: { } } registrationWithParameters)
arguments = UpdateArgumentsWithRegistrationParameters(registrationWithParameters, arguments); arguments = UpdateArgumentsWithRegistrationParameters(registrationWithParameters, arguments);
T instance; T instance;
if (registration is ITypedRegistrationBase defaultRegistration) if (registration is IOpenGenericRegistration openGenericRegistration)
{
arguments = ResolveConstructorArguments(openGenericRegistration.ImplementationType, arguments, resolveStack);
//create generic implementation type from generic arguments of T
Type genericImplementationType = openGenericRegistration.ImplementationType.MakeGenericType(typeof(T).GenericTypeArguments);
instance = (T) Activator.CreateInstance(genericImplementationType, arguments);
}
else if (registration is ITypedRegistration defaultRegistration)
{ {
arguments = ResolveConstructorArguments(defaultRegistration.ImplementationType, arguments, resolveStack); arguments = ResolveConstructorArguments(defaultRegistration.ImplementationType, arguments, resolveStack);
instance = (T) Activator.CreateInstance(defaultRegistration.ImplementationType, arguments); instance = (T) Activator.CreateInstance(defaultRegistration.ImplementationType, arguments);
@ -435,15 +430,6 @@ namespace LightweightIocContainer
else //factory method set to create the instance else //factory method set to create the instance
instance = singleTypeRegistration.FactoryMethod(this); instance = singleTypeRegistration.FactoryMethod(this);
} }
else if (registration is IOpenGenericRegistration openGenericRegistration)
{
arguments = ResolveConstructorArguments(openGenericRegistration.ImplementationType, arguments, resolveStack);
//create generic implementation type from generic arguments of T
Type genericImplementationType = openGenericRegistration.ImplementationType.MakeGenericType(typeof(T).GenericTypeArguments);
instance = (T) Activator.CreateInstance(genericImplementationType, arguments);
}
else else
throw new UnknownRegistrationException($"There is no registration of type {registration.GetType().Name}."); throw new UnknownRegistrationException($"There is no registration of type {registration.GetType().Name}.");
@ -456,11 +442,10 @@ namespace LightweightIocContainer
/// <summary> /// <summary>
/// Update the given arguments with the <see cref="IWithParameters{TInterface}.Parameters"/> of the given <see cref="IRegistrationBase{TInterface}"/> /// Update the given arguments with the <see cref="IWithParameters{TInterface}.Parameters"/> of the given <see cref="IRegistrationBase{TInterface}"/>
/// </summary> /// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <param name="registration">The <see cref="IRegistrationBase{TInterface}"/> of the given <see cref="Type"/></param> /// <param name="registration">The <see cref="IRegistrationBase{TInterface}"/> of the given <see cref="Type"/></param>
/// <param name="arguments">The constructor arguments</param> /// <param name="arguments">The constructor arguments</param>
/// <returns>The argument list updated with the <see cref="IWithParameters{TInterface}.Parameters"/></returns> /// <returns>The argument list updated with the <see cref="IWithParameters{TInterface}.Parameters"/></returns>
private object[] UpdateArgumentsWithRegistrationParameters<T>(IWithParameters<T> registration, object[] arguments) private object[] UpdateArgumentsWithRegistrationParameters(IWithParameters registration, object[] arguments)
{ {
if (arguments != null && arguments.Any()) //if more arguments were passed to resolve if (arguments != null && arguments.Any()) //if more arguments were passed to resolve
{ {
@ -588,7 +573,7 @@ namespace LightweightIocContainer
if (registration != null) if (registration != null)
return registration; return registration;
registration = _registrations.OfType<ITypedRegistrationBase>().FirstOrDefault(r => r.ImplementationType == typeof(T)); registration = _registrations.OfType<ITypedRegistration>().FirstOrDefault(r => r.ImplementationType == typeof(T));
if (registration != null) if (registration != null)
return registration; return registration;
@ -610,7 +595,7 @@ namespace LightweightIocContainer
public void ClearMultitonInstances<T>() public void ClearMultitonInstances<T>()
{ {
IRegistration registration = FindRegistration<T>(); IRegistration registration = FindRegistration<T>();
if (!(registration is IMultitonRegistration<T> multitonRegistration)) if (!(registration is IMultitonRegistration multitonRegistration))
return; return;
var multitonInstance = _multitons.FirstOrDefault(m => m.type == multitonRegistration.ImplementationType); var multitonInstance = _multitons.FirstOrDefault(m => m.type == multitonRegistration.ImplementationType);

@ -280,11 +280,24 @@
</summary> </summary>
<typeparam name="TFactory">The type of the abstract factory</typeparam> <typeparam name="TFactory">The type of the abstract factory</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Factories.TypedFactory`1.#ctor(LightweightIocContainer.Interfaces.IIocContainer)">
<summary>
The
</summary>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="P:LightweightIocContainer.Factories.TypedFactory`1.Factory"> <member name="P:LightweightIocContainer.Factories.TypedFactory`1.Factory">
<summary> <summary>
The implemented abstract typed factory/> The implemented abstract typed factory/>
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Factories.TypedFactory`1.CreateFactory(LightweightIocContainer.Interfaces.IIocContainer)">
<summary>
Creates the factory from the given abstract factory type
</summary>
<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.GenericMethodCaller"> <member name="T:LightweightIocContainer.GenericMethodCaller">
<summary> <summary>
Helper class to call a generic method without generic type parameters Helper class to call a generic method without generic type parameters
@ -372,7 +385,7 @@
</summary> </summary>
<typeparam name="TInterface">The Interface to register</typeparam> <typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</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.IRegistrationBase`1"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.RegisterOpenGenerics(System.Type,System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.RegisterOpenGenerics(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
@ -381,7 +394,7 @@
</summary> </summary>
<param name="tInterface">The open generic Interface to register</param> <param name="tInterface">The open generic Interface to register</param>
<param name="tImplementation">The open generic Type that implements the interface</param> <param name="tImplementation">The open generic Type that implements the interface</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IOpenGenericRegistration"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``3(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``3(LightweightIocContainer.Lifestyle)">
@ -391,7 +404,7 @@
<typeparam name="TInterface1">The base interface to register</typeparam> <typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam> <typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``4(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``4(LightweightIocContainer.Lifestyle)">
@ -402,7 +415,7 @@
<typeparam name="TInterface2">A second interface to register</typeparam> <typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``5(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``5(LightweightIocContainer.Lifestyle)">
@ -414,7 +427,7 @@
<typeparam name="TInterface3">A third interface to register</typeparam> <typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``6(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``6(LightweightIocContainer.Lifestyle)">
@ -427,7 +440,7 @@
<typeparam name="TInterface4">A fourth interface to register</typeparam> <typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``1(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``1(LightweightIocContainer.Lifestyle)">
@ -435,7 +448,7 @@
Register a <see cref="T:System.Type"/> without an interface Register a <see cref="T:System.Type"/> without an interface
</summary> </summary>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> to register</typeparam> <typeparam name="TImplementation">The <see cref="T:System.Type"/> to register</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.RegisterMultiton``3"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.RegisterMultiton``3">
@ -457,13 +470,6 @@
<typeparam name="TScope">The Type of the multiton scope</typeparam> <typeparam name="TScope">The Type of the multiton scope</typeparam>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.RegisterFactory``1">
<summary>
Register an Interface as an abstract typed factory
</summary>
<typeparam name="TFactory">The abstract typed factory to register</typeparam>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1">
<summary> <summary>
Gets an instance of the given <see cref="T:System.Type"/> Gets an instance of the given <see cref="T:System.Type"/>
@ -513,67 +519,59 @@
</summary> </summary>
<param name="container">The current <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param> <param name="container">The current <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate"> <member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate">
<summary> <summary>
Provides an <see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate.OnCreateAction"/> to the generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2"/> Provides an <see cref="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate.OnCreateAction"/> to the generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2"/>
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate.OnCreateAction"> <member name="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate.OnCreateAction">
<summary> <summary>
This <see cref="T:System.Action"/> is invoked when an instance of this type is created. 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> <para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2.OnCreate(System.Action{`1})"/></para>
</summary> </summary>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2"> <member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2">
<summary> <summary>
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"/> Provides an <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2.OnCreate(System.Action{`1})"/> method to an <see cref="!:IRegistrationBase&lt;TInterface&gt;"/>
</summary> </summary>
<typeparam name="TInterface">The registered interface</typeparam> <typeparam name="TInterface">The registered interface</typeparam>
<typeparam name="TImplementation">The registered implementation</typeparam> <typeparam name="TImplementation">The registered implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`1})"> <member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2.OnCreate(System.Action{`1})">
<summary> <summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary> </summary>
<param name="action">The <see cref="T:System.Action`1"/></param> <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> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1"> <member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters">
<summary> <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"/> Provides a <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</summary> </summary>
<typeparam name="TInterface">The registered interface</typeparam>
</member> </member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters"> <member name="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.Parameters">
<summary> <summary>
An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.WithParameters(System.Object[])"/></para> <para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])"/></para>
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.WithParameters(System.Object[])"> <member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])">
<summary> <summary>
Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
</summary> </summary>
<param name="parameters">The parameters</param> <param name="parameters">The parameters</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns> <returns>The current instance of this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></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> <exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.Parameters"/> are already set or no parameters given</exception>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.WithParameters(System.ValueTuple{System.Int32,System.Object}[])"> <member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.ValueTuple{System.Int32,System.Object}[])">
<summary> <summary>
Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving</para> <para>Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving</para>
</summary> </summary>
<param name="parameters">The parameters with their position</param> <param name="parameters">The parameters with their position</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns> <returns>The current instance of this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></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> <exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.Parameters"/> are already set or no parameters given</exception>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2">
<summary>
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>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ILifestyleProvider"> <member name="T:LightweightIocContainer.Interfaces.Registrations.ILifestyleProvider">
<summary> <summary>
@ -587,7 +585,7 @@
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleMultitonRegistration`3"> <member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleMultitonRegistration`3">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type that implements them as a multiton An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type that implements them as a multiton
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
@ -607,7 +605,7 @@
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"> <member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
@ -615,7 +613,7 @@
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"> <member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
@ -624,7 +622,7 @@
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"> <member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
@ -634,7 +632,7 @@
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`6"> <member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`6">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
@ -645,15 +643,10 @@
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration"> <member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration">
<summary> <summary>
Non generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"/> Non generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/>
</summary> </summary>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"> <member name="P:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration.Scope">
<summary>
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"/> without implementation
</summary>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1.Scope">
<summary> <summary>
The <see cref="T:System.Type"/> of the multiton scope The <see cref="T:System.Type"/> of the multiton scope
</summary> </summary>
@ -670,42 +663,21 @@
<see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IOpenGenericRegistration.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.IOpenGenericRegistration"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"> <member name="T:LightweightIocContainer.Interfaces.Registrations.IRegistration">
<summary> <summary>
The base registration that is used to register an Interface The base registration that is used to register an Interface
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.Name">
<summary>
The name of the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"> <member name="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType">
<summary> <summary>
The <see cref="T:System.Type"/> of the Interface that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> The <see cref="T:System.Type"/> of the Interface that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</summary> </summary>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase">
<summary>
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/> without generic interface
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1">
<summary>
The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that is used to register an Interface
</summary>
<typeparam name="TInterface">The registered Interface</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1"> <member name="T:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1">
<summary> <summary>
The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register either only an interface or only a <see cref="T:System.Type"/> The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register either only an interface or only a <see cref="T:System.Type"/>
</summary> </summary>
<typeparam name="T">The <see cref="T:System.Type"/> of the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></typeparam> <typeparam name="T">The <see cref="T:System.Type"/> of the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></typeparam>
</member> </member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1.FactoryMethod"> <member name="P:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1.FactoryMethod">
<summary> <summary>
@ -717,7 +689,7 @@
Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way
</summary> </summary>
<param name="factoryMethod">The <see cref="T:System.Func`2"/></param> <param name="factoryMethod">The <see cref="T:System.Func`2"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1"> <member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1">
<summary> <summary>
@ -730,24 +702,19 @@
The class that contains the implemented abstract factory of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1"/> The class that contains the implemented abstract factory of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1"/>
</summary> </summary>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase"> <member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration">
<summary> <summary>
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase"/> without generic interface and implementation A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration"/> without generic interface and implementation
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase.ImplementationType"> <member name="P:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration.ImplementationType">
<summary> <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"/> 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.IRegistration"/>
</summary> </summary>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`1"> <member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2">
<summary> <summary>
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`1"/> without generic implementation A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> that implements a <see cref="T:System.Type"/>
</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> </summary>
</member> </member>
<member name="T:LightweightIocContainer.InternalResolvePlaceholder"> <member name="T:LightweightIocContainer.InternalResolvePlaceholder">
@ -778,7 +745,7 @@
</summary> </summary>
<typeparam name="TInterface">The Interface to register</typeparam> <typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</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.IRegistrationBase`1"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.RegisterOpenGenerics(System.Type,System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.IocContainer.RegisterOpenGenerics(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
@ -799,7 +766,7 @@
<typeparam name="TInterface1">The base interface to register</typeparam> <typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam> <typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.Register``4(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.IocContainer.Register``4(LightweightIocContainer.Lifestyle)">
@ -810,7 +777,7 @@
<typeparam name="TInterface2">A second interface to register</typeparam> <typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.Register``5(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.IocContainer.Register``5(LightweightIocContainer.Lifestyle)">
@ -822,7 +789,7 @@
<typeparam name="TInterface3">A third interface to register</typeparam> <typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.Register``6(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.IocContainer.Register``6(LightweightIocContainer.Lifestyle)">
@ -835,7 +802,7 @@
<typeparam name="TInterface4">A fourth interface to register</typeparam> <typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.Register``1(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.IocContainer.Register``1(LightweightIocContainer.Lifestyle)">
@ -843,7 +810,7 @@
Register a <see cref="T:System.Type"/> without an interface Register a <see cref="T:System.Type"/> without an interface
</summary> </summary>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> to register</typeparam> <typeparam name="TImplementation">The <see cref="T:System.Type"/> to register</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.RegisterMultiton``3"> <member name="M:LightweightIocContainer.IocContainer.RegisterMultiton``3">
@ -865,7 +832,7 @@
<typeparam name="TScope">The Type of the multiton scope</typeparam> <typeparam name="TScope">The Type of the multiton scope</typeparam>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.RegisterFactory``1"> <member name="M:LightweightIocContainer.IocContainer.RegisterFactory``1(LightweightIocContainer.Interfaces.Factories.ITypedFactory{``0})">
<summary> <summary>
Register an Interface as an abstract typed factory Register an Interface as an abstract typed factory
</summary> </summary>
@ -933,7 +900,7 @@
<param name="resolveStack">The current resolve stack</param> <param name="resolveStack">The current resolve stack</param>
<returns>An existing or newly created singleton instance of the given <see cref="T:System.Type"/></returns> <returns>An existing or newly created singleton instance of the given <see cref="T:System.Type"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.GetOrCreateMultitonInstance``1(LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration{``0},System.Object[],System.Collections.Generic.List{System.Type})"> <member name="M:LightweightIocContainer.IocContainer.GetOrCreateMultitonInstance``1(LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration,System.Object[],System.Collections.Generic.List{System.Type})">
<summary> <summary>
Gets or creates a multiton instance of a given <see cref="T:System.Type"/> Gets or creates a multiton instance of a given <see cref="T:System.Type"/>
</summary> </summary>
@ -955,14 +922,13 @@
<param name="resolveStack">The current resolve stack</param> <param name="resolveStack">The current resolve stack</param>
<returns>A newly created instance of the given <see cref="T:System.Type"/></returns> <returns>A newly created instance of the given <see cref="T:System.Type"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.UpdateArgumentsWithRegistrationParameters``1(LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters{``0},System.Object[])"> <member name="M:LightweightIocContainer.IocContainer.UpdateArgumentsWithRegistrationParameters(LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters,System.Object[])">
<summary> <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"/> Update the given arguments with the <see cref="!:IWithParameters&lt;TInterface&gt;.Parameters"/> of the given <see cref="!:IRegistrationBase&lt;TInterface&gt;"/>
</summary> </summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam> <param name="registration">The <see cref="!:IRegistrationBase&lt;TInterface&gt;"/> of the given <see cref="T:System.Type"/></param>
<param name="registration">The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> of the given <see cref="T:System.Type"/></param>
<param name="arguments">The constructor arguments</param> <param name="arguments">The constructor arguments</param>
<returns>The argument list updated with the <see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters"/></returns> <returns>The argument list updated with the <see cref="!:IWithParameters&lt;TInterface&gt;.Parameters"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.IocContainer.ResolveConstructorArguments(System.Type,System.Object[],System.Collections.Generic.List{System.Type})"> <member name="M:LightweightIocContainer.IocContainer.ResolveConstructorArguments(System.Type,System.Object[],System.Collections.Generic.List{System.Type})">
<summary> <summary>
@ -994,7 +960,7 @@
</member> </member>
<member name="T:LightweightIocContainer.Lifestyle"> <member name="T:LightweightIocContainer.Lifestyle">
<summary> <summary>
The Lifestyles that can be used for a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> The Lifestyles that can be used for a <see cref="!:IRegistrationBase&lt;TInterface&gt;"/>
</summary> </summary>
</member> </member>
<member name="F:LightweightIocContainer.Lifestyle.Transient"> <member name="F:LightweightIocContainer.Lifestyle.Transient">
@ -1012,37 +978,23 @@
A new instance gets created if the given scope has no created instance yet. Otherwise the already created instance is used. A new instance gets created if the given scope has no created instance yet. Otherwise the already created instance is used.
</summary> </summary>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.DefaultRegistration`2">
<summary>
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`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
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="T:LightweightIocContainer.Registrations.MultipleMultitonRegistration`3"> <member name="T:LightweightIocContainer.Registrations.MultipleMultitonRegistration`3">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type that implements them as a multiton An <see cref="!:IRegistrationBase&lt;TInterface&gt;"/> to register multiple interfaces for on implementation type that implements them as a multiton
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam> <typeparam name="TImplementation">The implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleMultitonRegistration`3.#ctor(System.Type,System.Type,System.Type,System.Type)"> <member name="M:LightweightIocContainer.Registrations.MultipleMultitonRegistration`3.#ctor(System.Type,System.Type,System.Type,System.Type,LightweightIocContainer.IocContainer)">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type that implements them as a multiton An <see cref="!:IRegistrationBase&lt;TInterface&gt;"/> to register multiple interfaces for on implementation type that implements them as a multiton
</summary> </summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param> <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="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param> <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> <param name="scope">The <see cref="T:System.Type"/> of the multiton scope</param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.MultipleMultitonRegistration`3.Registrations"> <member name="P:LightweightIocContainer.Registrations.MultipleMultitonRegistration`3.Registrations">
<summary> <summary>
@ -1054,7 +1006,7 @@
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary> </summary>
<param name="action">The <see cref="T:System.Action`1"/></param> <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> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`2"> <member name="T:LightweightIocContainer.Registrations.MultipleRegistration`2">
<summary> <summary>
@ -1063,13 +1015,14 @@
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam> <typeparam name="TImplementation">The implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.MultipleRegistration`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle,LightweightIocContainer.IocContainer)">
<summary> <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`2"/> to register multiple interfaces
</summary> </summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param> <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="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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.MultipleRegistration`2.Registrations"> <member name="P:LightweightIocContainer.Registrations.MultipleRegistration`2.Registrations">
<summary> <summary>
@ -1078,57 +1031,59 @@
</member> </member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`3"> <member name="T:LightweightIocContainer.Registrations.MultipleRegistration`3">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam> <typeparam name="TImplementation">The implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.#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,LightweightIocContainer.IocContainer)">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param> <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="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.OnCreate(System.Action{`2})"> <member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.OnCreate(System.Action{`2})">
<summary> <summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary> </summary>
<param name="action">The <see cref="T:System.Action`1"/></param> <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> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`4"> <member name="T:LightweightIocContainer.Registrations.MultipleRegistration`4">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TInterface3">The third interface</typeparam> <typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam> <typeparam name="TImplementation">The implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.#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,LightweightIocContainer.IocContainer)">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param> <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="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="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="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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.OnCreate(System.Action{`3})"> <member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.OnCreate(System.Action{`3})">
<summary> <summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary> </summary>
<param name="action">The <see cref="T:System.Action`1"/></param> <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> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`5"> <member name="T:LightweightIocContainer.Registrations.MultipleRegistration`5">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
@ -1136,9 +1091,9 @@
<typeparam name="TInterface4">The fourth interface</typeparam> <typeparam name="TInterface4">The fourth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam> <typeparam name="TImplementation">The implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.#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,LightweightIocContainer.IocContainer)">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param> <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="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
@ -1146,17 +1101,18 @@
<param name="interfaceType4">The <see cref="T:System.Type"/> of the fourth 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="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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.OnCreate(System.Action{`4})"> <member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.OnCreate(System.Action{`4})">
<summary> <summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary> </summary>
<param name="action">The <see cref="T:System.Action`1"/></param> <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> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`6"> <member name="T:LightweightIocContainer.Registrations.MultipleRegistration`6">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<typeparam name="TInterface1">The first interface</typeparam> <typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam> <typeparam name="TInterface2">The second interface</typeparam>
@ -1165,9 +1121,9 @@
<typeparam name="TInterface5">The fifth interface</typeparam> <typeparam name="TInterface5">The fifth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam> <typeparam name="TImplementation">The implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`6.#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,LightweightIocContainer.IocContainer)">
<summary> <summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary> </summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param> <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="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
@ -1176,13 +1132,14 @@
<param name="interfaceType5">The <see cref="T:System.Type"/> of the fifth 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="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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`6.OnCreate(System.Action{`5})"> <member name="M:LightweightIocContainer.Registrations.MultipleRegistration`6.OnCreate(System.Action{`5})">
<summary> <summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary> </summary>
<param name="action">The <see cref="T:System.Action`1"/></param> <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> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.MultitonRegistration`2"> <member name="T:LightweightIocContainer.Registrations.MultitonRegistration`2">
<summary> <summary>
@ -1191,13 +1148,14 @@
<typeparam name="TInterface">The registered interface</typeparam> <typeparam name="TInterface">The registered interface</typeparam>
<typeparam name="TImplementation">The registered implementation</typeparam> <typeparam name="TImplementation">The registered implementation</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.MultitonRegistration`2.#ctor(System.Type,System.Type,System.Type)"> <member name="M:LightweightIocContainer.Registrations.MultitonRegistration`2.#ctor(System.Type,System.Type,System.Type,LightweightIocContainer.IocContainer)">
<summary> <summary>
The registration that is used to register a multiton The registration that is used to register a multiton
</summary> </summary>
<param name="interfaceType">The <see cref="T:System.Type"/> of the Interface</param> <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="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> <param name="scope">The <see cref="T:System.Type"/> of the Multiton Scope</param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.MultitonRegistration`2.Scope"> <member name="P:LightweightIocContainer.Registrations.MultitonRegistration`2.Scope">
<summary> <summary>
@ -1209,85 +1167,66 @@
<see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.OpenGenericRegistration.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.OpenGenericRegistration.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle,LightweightIocContainer.IocContainer)">
<summary> <summary>
<see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types
</summary> </summary>
<param name="interfaceType">The <see cref="T:System.Type"/> of the interface</param> <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 type</param> <param name="implementationType">The <see cref="T:System.Type"/> of the implementation type</param>
<param name="lifestyle">The <see cref="P:LightweightIocContainer.Registrations.OpenGenericRegistration.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IOpenGenericRegistration"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IOpenGenericRegistration"/></param>
</member> <param name="iocContainer">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
<member name="P:LightweightIocContainer.Registrations.OpenGenericRegistration.Name">
<summary>
The name of the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Registrations.OpenGenericRegistration.InterfaceType">
<summary>
The <see cref="T:System.Type"/> of the Interface that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</summary>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.OpenGenericRegistration.ImplementationType"> <member name="P:LightweightIocContainer.Registrations.OpenGenericRegistration.ImplementationType">
<summary> <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.IOpenGenericRegistration"/> 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.IOpenGenericRegistration"/>
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.OpenGenericRegistration.Lifestyle"> <member name="T:LightweightIocContainer.Registrations.RegistrationBase">
<summary> <summary>
The Lifestyle of Instances that are created with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> The <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/> that is used to register an Interface
</summary>
</member>
<member name="T:LightweightIocContainer.Registrations.RegistrationBase`1">
<summary>
The <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/> that is used to register an Interface
</summary> </summary>
<typeparam name="TInterface">The registered Interface</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase`1.#ctor(System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.RegistrationBase.#ctor(System.Type,LightweightIocContainer.Lifestyle,LightweightIocContainer.IocContainer)">
<summary> <summary>
The <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/> that is used to register an Interface The <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/> that is used to register an Interface
</summary> </summary>
<param name="interfaceType">The <see cref="T:System.Type"/> of the Interface</param> <param name="interfaceType">The <see cref="T:System.Type"/> of the Interface</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of the registration</param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of the registration</param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase`1.Name"> <member name="P:LightweightIocContainer.Registrations.RegistrationBase.InterfaceType">
<summary>
The name of the <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase`1.InterfaceType">
<summary> <summary>
The <see cref="T:System.Type"/> of the Interface that is registered with this <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/> The <see cref="T:System.Type"/> of the Interface that is registered with this <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/>
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase`1.Lifestyle"> <member name="P:LightweightIocContainer.Registrations.RegistrationBase.Lifestyle">
<summary> <summary>
The <see cref="T:LightweightIocContainer.Lifestyle"/> of Instances that are created with this <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/> The <see cref="T:LightweightIocContainer.Lifestyle"/> of Instances that are created with this <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/>
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase`1.Parameters"> <member name="P:LightweightIocContainer.Registrations.RegistrationBase.Parameters">
<summary> <summary>
An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Registrations.RegistrationBase`1.WithParameters(System.Object[])"/></para> <para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.Object[])"/></para>
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase`1.WithParameters(System.Object[])"> <member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.Object[])">
<summary> <summary>
Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
</summary> </summary>
<param name="parameters">The parameters</param> <param name="parameters">The parameters</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
<exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Registrations.RegistrationBase`1.Parameters"/> are already set or no parameters given</exception> <exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Registrations.RegistrationBase.Parameters"/> are already set or no parameters given</exception>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase`1.WithParameters(System.ValueTuple{System.Int32,System.Object}[])"> <member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.ValueTuple{System.Int32,System.Object}[])">
<summary> <summary>
Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving</para> <para>Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving</para>
</summary> </summary>
<param name="parameters">The parameters with their position</param> <param name="parameters">The parameters with their position</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
<exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Registrations.RegistrationBase`1.Parameters"/> are already set or no parameters given</exception> <exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Registrations.RegistrationBase.Parameters"/> are already set or no parameters given</exception>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.RegistrationFactory"> <member name="T:LightweightIocContainer.Registrations.RegistrationFactory">
<summary> <summary>
@ -1296,12 +1235,12 @@
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``2(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``2(LightweightIocContainer.Lifestyle)">
<summary> <summary>
Register an Interface with a Type that implements it and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/> Register an Interface with a Type that implements it and create a <see cref="!:IDefaultRegistration&lt;TInterface,TImplementation&gt;"/>
</summary> </summary>
<typeparam name="TInterface">The Interface to register</typeparam> <typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</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`2"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IDefaultRegistration&lt;TInterface,TImplementation&gt;"/></param>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/> with the given parameters</returns> <returns>A new created <see cref="!:IDefaultRegistration&lt;TInterface,TImplementation&gt;"/> with the given parameters</returns>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register(System.Type,System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary> <summary>
@ -1319,7 +1258,7 @@
<typeparam name="TInterface1">The base interface to register</typeparam> <typeparam name="TInterface1">The base interface to register</typeparam>
<typeparam name="TInterface2">A second interface to register</typeparam> <typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``4(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``4(LightweightIocContainer.Lifestyle)">
@ -1330,7 +1269,7 @@
<typeparam name="TInterface2">A second interface to register</typeparam> <typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``5(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``5(LightweightIocContainer.Lifestyle)">
@ -1342,7 +1281,7 @@
<typeparam name="TInterface3">A third interface to register</typeparam> <typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``6(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``6(LightweightIocContainer.Lifestyle)">
@ -1355,7 +1294,7 @@
<typeparam name="TInterface4">A fourth interface to register</typeparam> <typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth 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> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``1(LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``1(LightweightIocContainer.Lifestyle)">
@ -1385,7 +1324,7 @@
<typeparam name="TScope">The Type of the multiton scope</typeparam> <typeparam name="TScope">The Type of the multiton scope</typeparam>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleMultitonRegistration`3"/> with the given parameters</returns> <returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleMultitonRegistration`3"/> with the given parameters</returns>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.RegisterFactory``1"> <member name="M:LightweightIocContainer.Registrations.RegistrationFactory.RegisterFactory``1(LightweightIocContainer.Interfaces.Factories.ITypedFactory{``0})">
<summary> <summary>
Register an Interface as an abstract typed factory and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1"/> Register an Interface as an abstract typed factory and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1"/>
</summary> </summary>
@ -1394,16 +1333,17 @@
</member> </member>
<member name="T:LightweightIocContainer.Registrations.SingleTypeRegistration`1"> <member name="T:LightweightIocContainer.Registrations.SingleTypeRegistration`1">
<summary> <summary>
The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register either only an interface or only a <see cref="T:System.Type"/> The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register either only an interface or only a <see cref="T:System.Type"/>
</summary> </summary>
<typeparam name="T">The <see cref="T:System.Type"/> of the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></typeparam> <typeparam name="T">The <see cref="T:System.Type"/> of the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.SingleTypeRegistration`1.#ctor(System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.SingleTypeRegistration`1.#ctor(System.Type,LightweightIocContainer.Lifestyle,LightweightIocContainer.IocContainer)">
<summary> <summary>
The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register either only an interface or only a <see cref="T:System.Type"/> The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register either only an interface or only a <see cref="T:System.Type"/>
</summary> </summary>
<param name="interfaceType">The <see cref="T:System.Type"/> of the interface or <see cref="T:System.Type"/></param> <param name="interfaceType">The <see cref="T:System.Type"/> of the interface or <see cref="T:System.Type"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of the <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/></param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of the <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.SingleTypeRegistration`1.FactoryMethod"> <member name="P:LightweightIocContainer.Registrations.SingleTypeRegistration`1.FactoryMethod">
<summary> <summary>
@ -1415,7 +1355,7 @@
Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way
</summary> </summary>
<param name="factoryMethod">The <see cref="T:System.Func`2"/></param> <param name="factoryMethod">The <see cref="T:System.Func`2"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1"> <member name="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1">
<summary> <summary>
@ -1423,21 +1363,15 @@
</summary> </summary>
<typeparam name="TFactory">The <see cref="T:System.Type"/> of the abstract typed factory</typeparam> <typeparam name="TFactory">The <see cref="T:System.Type"/> of the abstract typed factory</typeparam>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.#ctor(System.Type,LightweightIocContainer.Interfaces.IIocContainer)"> <member name="M:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.#ctor(LightweightIocContainer.Interfaces.Factories.ITypedFactory{`0})">
<summary> <summary>
The registration that is used to register an abstract typed factory The registration that is used to register an abstract typed factory
</summary> </summary>
<param name="factoryType">The <see cref="T:System.Type"/> of the abstract typed factory</param> <param name="factory">The <see cref="T:LightweightIocContainer.Interfaces.Factories.ITypedFactory`1"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.Name">
<summary>
The name of the <see cref="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1"/>
</summary>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.InterfaceType"> <member name="P:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.InterfaceType">
<summary> <summary>
The <see cref="T:System.Type"/> of the abstract typed factory that is registered with this <see cref="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1"/> The <see cref="T:System.Type"/> of the factory that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.Factory"> <member name="P:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.Factory">
@ -1445,43 +1379,37 @@
The class that contains the implemented abstract factory of this <see cref="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1"/> The class that contains the implemented abstract factory of this <see cref="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1"/>
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.CreateFactory(LightweightIocContainer.Interfaces.IIocContainer)"> <member name="T:LightweightIocContainer.Registrations.TypedRegistration`2">
<summary>
Creates the factory from the given abstract factory type
</summary>
<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`2">
<summary> <summary>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/> A <see cref="!:IRegistrationBase&lt;TInterface&gt;"/> that implements a <see cref="T:System.Type"/>
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.TypedRegistrationBase`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle)"> <member name="M:LightweightIocContainer.Registrations.TypedRegistration`2.#ctor(System.Type,System.Type,LightweightIocContainer.Lifestyle,LightweightIocContainer.IocContainer)">
<summary> <summary>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/> A <see cref="!:IRegistrationBase&lt;TInterface&gt;"/> that implements a <see cref="T:System.Type"/>
</summary> </summary>
<param name="interfaceType">The <see cref="T:System.Type"/> of the interface</param> <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 type</param> <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> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.TypedRegistrationBase`2.ImplementationType"> <member name="P:LightweightIocContainer.Registrations.TypedRegistration`2.ImplementationType">
<summary> <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"/> The <see cref="T:System.Type"/> that implements the <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> that is registered with this <see cref="!:IRegistrationBase&lt;TInterface&gt;"/>
</summary> </summary>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.TypedRegistrationBase`2.OnCreateAction"> <member name="P:LightweightIocContainer.Registrations.TypedRegistration`2.OnCreateAction">
<summary> <summary>
This <see cref="T:System.Action"/> is invoked when an instance of this type is created. 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> <para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2.OnCreate(System.Action{`1})"/></para>
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.TypedRegistrationBase`2.OnCreate(System.Action{`1})"> <member name="M:LightweightIocContainer.Registrations.TypedRegistration`2.OnCreate(System.Action{`1})">
<summary> <summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary> </summary>
<param name="action">The <see cref="T:System.Action`1"/></param> <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> <returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.TypeExtension.GetDefault(System.Type)"> <member name="M:LightweightIocContainer.TypeExtension.GetDefault(System.Type)">
<summary> <summary>

@ -1,27 +0,0 @@
// Author: Gockner, Simon
// Created: 2019-11-22
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
/// <summary>
/// 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>
/// <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,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>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of the <see cref="RegistrationBase{TInterface}"/></param>
public DefaultRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle)
: base(interfaceType, implementationType, lifestyle) =>
Name = $"{InterfaceType.Name}, {ImplementationType.Name}, Lifestyle: {Lifestyle.ToString()}";
}
}

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations
@ -23,13 +24,14 @@ namespace LightweightIocContainer.Registrations
/// <param name="interfaceType2">The <see cref="Type"/> of the second interface</param> /// <param name="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param> /// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="scope">The <see cref="Type"/> of the multiton scope</param> /// <param name="scope">The <see cref="Type"/> of the multiton scope</param>
public MultipleMultitonRegistration(Type interfaceType1, Type interfaceType2, Type implementationType, Type scope) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType1, implementationType, scope) public MultipleMultitonRegistration(Type interfaceType1, Type interfaceType2, Type implementationType, Type scope, IocContainer container)
: base(interfaceType1, implementationType, scope, container)
{ {
Registrations = new List<IRegistration>() Registrations = new List<IRegistration>()
{ {
new MultitonRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, scope), new MultitonRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, scope, container),
new MultitonRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, scope) new MultitonRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, scope, container)
}; };
} }
@ -42,8 +44,8 @@ namespace LightweightIocContainer.Registrations
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action) public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{ {
foreach (var registration in Registrations) foreach (var registration in Registrations)
{ {

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations
@ -13,7 +14,7 @@ namespace LightweightIocContainer.Registrations
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
public abstract class MultipleRegistration<TInterface1, TImplementation> : TypedRegistrationBase<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1 public abstract class MultipleRegistration<TInterface1, TImplementation> : TypedRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1
{ {
/// <summary> /// <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}"/> to register multiple interfaces
@ -21,8 +22,9 @@ namespace LightweightIocContainer.Registrations
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param> /// <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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
protected MultipleRegistration(Type interfaceType1, Type implementationType, Lifestyle lifestyle) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType1, implementationType, lifestyle) protected MultipleRegistration(Type interfaceType1, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType1, implementationType, lifestyle, container)
{ {
} }
@ -34,7 +36,7 @@ namespace LightweightIocContainer.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
@ -42,19 +44,20 @@ namespace LightweightIocContainer.Registrations
public class MultipleRegistration<TInterface1, TInterface2, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2 public class MultipleRegistration<TInterface1, TInterface2, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param> /// <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="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</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> /// <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) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType1, implementationType, lifestyle) public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType1, implementationType, lifestyle, container)
{ {
Registrations = new List<IRegistration>() Registrations = new List<IRegistration>
{ {
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle), new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle) new TypedRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle, container)
}; };
} }
@ -62,14 +65,14 @@ namespace LightweightIocContainer.Registrations
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action) public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{ {
foreach (var registration in Registrations) foreach (var registration in Registrations)
{ {
if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration) if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action); interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration) else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action); interface1Registration.OnCreate(action);
} }
@ -78,7 +81,7 @@ namespace LightweightIocContainer.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
@ -87,21 +90,22 @@ namespace LightweightIocContainer.Registrations
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> where TImplementation : TInterface3, TInterface2, TInterface1 public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> where TImplementation : TInterface3, TInterface2, TInterface1
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param> /// <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="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="interfaceType3">The <see cref="Type"/> of the third 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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></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) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType1, implementationType, lifestyle) public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType1, implementationType, lifestyle, container)
{ {
Registrations = new List<IRegistration>() Registrations = new List<IRegistration>
{ {
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle), new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle), new TypedRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle, container),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle) new TypedRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle, container)
}; };
} }
@ -109,16 +113,16 @@ namespace LightweightIocContainer.Registrations
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action) public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{ {
foreach (var registration in Registrations) foreach (var registration in Registrations)
{ {
if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration) if (registration is ITypedRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action); interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration) else if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action); interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration) else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action); interface1Registration.OnCreate(action);
} }
@ -127,7 +131,7 @@ namespace LightweightIocContainer.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
@ -137,7 +141,7 @@ namespace LightweightIocContainer.Registrations
public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1 public class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param> /// <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="interfaceType2">The <see cref="Type"/> of the second interface</param>
@ -145,15 +149,16 @@ namespace LightweightIocContainer.Registrations
/// <param name="interfaceType4">The <see cref="Type"/> of the fourth 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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></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) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType1, implementationType, lifestyle) public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type interfaceType4, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType1, implementationType, lifestyle, container)
{ {
Registrations = new List<IRegistration>() Registrations = new List<IRegistration>
{ {
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle), new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle), new TypedRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle, container),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle), new TypedRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle, container),
new DefaultRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle) new TypedRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle, container)
}; };
} }
@ -161,18 +166,18 @@ namespace LightweightIocContainer.Registrations
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action) public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{ {
foreach (var registration in Registrations) foreach (var registration in Registrations)
{ {
if (registration is IDefaultRegistration<TInterface4, TImplementation> interface4Registration) if (registration is ITypedRegistration<TInterface4, TImplementation> interface4Registration)
interface4Registration.OnCreate(action); interface4Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration) else if (registration is ITypedRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action); interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration) else if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action); interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration) else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action); interface1Registration.OnCreate(action);
} }
@ -181,7 +186,7 @@ namespace LightweightIocContainer.Registrations
} }
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
@ -192,7 +197,7 @@ namespace LightweightIocContainer.Registrations
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 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> /// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param> /// <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="interfaceType2">The <see cref="Type"/> of the second interface</param>
@ -201,16 +206,17 @@ namespace LightweightIocContainer.Registrations
/// <param name="interfaceType5">The <see cref="Type"/> of the fifth 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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></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) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType1, implementationType, lifestyle) public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type interfaceType4, Type interfaceType5, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType1, implementationType, lifestyle, container)
{ {
Registrations = new List<IRegistration>() Registrations = new List<IRegistration>
{ {
new DefaultRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle), new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
new DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle), new TypedRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle, container),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle), new TypedRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle, container),
new DefaultRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle), new TypedRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle, container),
new DefaultRegistration<TInterface5, TImplementation>(interfaceType5, implementationType, lifestyle) new TypedRegistration<TInterface5, TImplementation>(interfaceType5, implementationType, lifestyle, container)
}; };
} }
@ -218,20 +224,20 @@ namespace LightweightIocContainer.Registrations
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action) public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{ {
foreach (var registration in Registrations) foreach (var registration in Registrations)
{ {
if (registration is IDefaultRegistration<TInterface5, TImplementation> interface5Registration) if (registration is ITypedRegistration<TInterface5, TImplementation> interface5Registration)
interface5Registration.OnCreate(action); interface5Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface4, TImplementation> interface4Registration) else if (registration is ITypedRegistration<TInterface4, TImplementation> interface4Registration)
interface4Registration.OnCreate(action); interface4Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration) else if (registration is ITypedRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action); interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration) else if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action); interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration) else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action); interface1Registration.OnCreate(action);
} }

@ -3,6 +3,7 @@
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
using System; using System;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations
@ -12,7 +13,7 @@ namespace LightweightIocContainer.Registrations
/// </summary> /// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam> /// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam> /// <typeparam name="TImplementation">The registered implementation</typeparam>
public class MultitonRegistration<TInterface, TImplementation> : DefaultRegistration<TInterface, TImplementation>, IMultitonRegistration<TInterface, TImplementation> where TImplementation : TInterface public class MultitonRegistration<TInterface, TImplementation> : TypedRegistration<TInterface, TImplementation>, IMultitonRegistration<TInterface, TImplementation> where TImplementation : TInterface
{ {
/// <summary> /// <summary>
/// The registration that is used to register a multiton /// The registration that is used to register a multiton
@ -20,8 +21,9 @@ namespace LightweightIocContainer.Registrations
/// <param name="interfaceType">The <see cref="Type"/> of the Interface</param> /// <param name="interfaceType">The <see cref="Type"/> of the Interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the Implementation</param> /// <param name="implementationType">The <see cref="Type"/> of the Implementation</param>
/// <param name="scope">The <see cref="Type"/> of the Multiton Scope</param> /// <param name="scope">The <see cref="Type"/> of the Multiton Scope</param>
public MultitonRegistration(Type interfaceType, Type implementationType, Type scope) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType, implementationType, Lifestyle.Multiton) => public MultitonRegistration(Type interfaceType, Type implementationType, Type scope, IocContainer container)
: base(interfaceType, implementationType, Lifestyle.Multiton, container) =>
Scope = scope; Scope = scope;
/// <summary> /// <summary>

@ -3,6 +3,7 @@
// Copyright(c) 2020 SimonG. All Rights Reserved. // Copyright(c) 2020 SimonG. All Rights Reserved.
using System; using System;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations
@ -10,7 +11,7 @@ namespace LightweightIocContainer.Registrations
/// <summary> /// <summary>
/// <see cref="IRegistration"/> for open generic types /// <see cref="IRegistration"/> for open generic types
/// </summary> /// </summary>
public class OpenGenericRegistration : IOpenGenericRegistration public class OpenGenericRegistration : RegistrationBase, IOpenGenericRegistration
{ {
/// <summary> /// <summary>
/// <see cref="IRegistration"/> for open generic types /// <see cref="IRegistration"/> for open generic types
@ -18,33 +19,14 @@ namespace LightweightIocContainer.Registrations
/// <param name="interfaceType">The <see cref="Type"/> of the interface</param> /// <param name="interfaceType">The <see cref="Type"/> of the interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation type</param> /// <param name="implementationType">The <see cref="Type"/> of the implementation type</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="IOpenGenericRegistration"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="IOpenGenericRegistration"/></param>
public OpenGenericRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle) /// <param name="iocContainer">The current instance of the <see cref="IIocContainer"/></param>
{ public OpenGenericRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle, IocContainer iocContainer)
InterfaceType = interfaceType; : base(interfaceType, lifestyle, iocContainer) =>
ImplementationType = implementationType; ImplementationType = implementationType;
Lifestyle = lifestyle;
Name = $"{InterfaceType.Name}, {ImplementationType.Name}, Lifestyle: {Lifestyle.ToString()}";
}
/// <summary>
/// The name of the <see cref="IRegistration"/>
/// </summary>
public string Name { get; }
/// <summary>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="IRegistration"/>
/// </summary>
public Type InterfaceType { get; }
/// <summary> /// <summary>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IOpenGenericRegistration"/> /// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IOpenGenericRegistration"/>
/// </summary> /// </summary>
public Type ImplementationType { get; } public Type ImplementationType { get; }
/// <summary>
/// The Lifestyle of Instances that are created with this <see cref="IRegistration"/>
/// </summary>
public Lifestyle Lifestyle { get; }
} }
} }

@ -5,41 +5,41 @@
using System; using System;
using System.Linq; using System.Linq;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Factories;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations
{ {
/// <summary> /// <summary>
/// The <see cref="RegistrationBase{TInterface}"/> that is used to register an Interface /// The <see cref="RegistrationBase"/> that is used to register an Interface
/// </summary> /// </summary>
/// <typeparam name="TInterface">The registered Interface</typeparam> public abstract class RegistrationBase : IRegistrationBase
public abstract class RegistrationBase<TInterface> : IRegistrationBase<TInterface>
{ {
private readonly IocContainer _container;
/// <summary> /// <summary>
/// The <see cref="RegistrationBase{TInterface}"/> that is used to register an Interface /// The <see cref="RegistrationBase"/> that is used to register an Interface
/// </summary> /// </summary>
/// <param name="interfaceType">The <see cref="Type"/> of the Interface</param> /// <param name="interfaceType">The <see cref="Type"/> of the Interface</param>
/// <param name="lifestyle">The <see cref="LightweightIocContainer.Lifestyle"/> of the registration</param> /// <param name="lifestyle">The <see cref="LightweightIocContainer.Lifestyle"/> of the registration</param>
protected RegistrationBase(Type interfaceType, Lifestyle lifestyle) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
protected RegistrationBase(Type interfaceType, Lifestyle lifestyle, IocContainer container)
{ {
InterfaceType = interfaceType; InterfaceType = interfaceType;
Lifestyle = lifestyle; Lifestyle = lifestyle;
_container = container;
} }
/// <summary> /// <summary>
/// The name of the <see cref="RegistrationBase{TInterface}"/> /// The <see cref="Type"/> of the Interface that is registered with this <see cref="RegistrationBase"/>
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="RegistrationBase{TInterface}"/>
/// </summary> /// </summary>
public Type InterfaceType { get; } public Type InterfaceType { get; }
/// <summary> /// <summary>
/// The <see cref="LightweightIocContainer.Lifestyle"/> of Instances that are created with this <see cref="RegistrationBase{TInterface}"/> /// The <see cref="LightweightIocContainer.Lifestyle"/> of Instances that are created with this <see cref="RegistrationBase"/>
/// </summary> /// </summary>
public Lifestyle Lifestyle { get; } public Lifestyle Lifestyle { get; }
@ -48,15 +48,17 @@ namespace LightweightIocContainer.Registrations
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="WithParameters(object[])"/></para> /// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="WithParameters(object[])"/></para>
/// </summary> /// </summary>
public object[] Parameters { get; private set; } public object[] Parameters { get; private set; }
public ITypedFactory Factory { get; private set; }
/// <summary> /// <summary>
/// Pass parameters that will be used to<see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// Pass parameters that will be used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> /// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
/// </summary> /// </summary>
/// <param name="parameters">The parameters</param> /// <param name="parameters">The parameters</param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistration"/></returns>
/// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception> /// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception>
public virtual IRegistrationBase<TInterface> WithParameters(params object[] parameters) public virtual IRegistrationBase WithParameters(params object[] parameters)
{ {
if (Parameters != null) if (Parameters != null)
throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType})."); throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType}).");
@ -73,9 +75,9 @@ namespace LightweightIocContainer.Registrations
/// <para>Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving</para> /// <para>Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving</para>
/// </summary> /// </summary>
/// <param name="parameters">The parameters with their position</param> /// <param name="parameters">The parameters with their position</param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistration"/></returns>
/// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception> /// <exception cref="InvalidRegistrationException"><see cref="Parameters"/> are already set or no parameters given</exception>
public virtual IRegistrationBase<TInterface> WithParameters(params (int index, object parameter)[] parameters) public virtual IRegistrationBase WithParameters(params (int index, object parameter)[] parameters)
{ {
if (Parameters != null) if (Parameters != null)
throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType})."); throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType}).");
@ -83,7 +85,7 @@ namespace LightweightIocContainer.Registrations
if (parameters == null || !parameters.Any()) if (parameters == null || !parameters.Any())
throw new InvalidRegistrationException($"No parameters given to `WithParameters()` method (Type: {InterfaceType})."); throw new InvalidRegistrationException($"No parameters given to `WithParameters()` method (Type: {InterfaceType}).");
var lastIndex = parameters.Max(p => p.index); int lastIndex = parameters.Max(p => p.index);
Parameters = new object[lastIndex + 1]; Parameters = new object[lastIndex + 1];
for (int i = 0; i < Parameters.Length; i++) for (int i = 0; i < Parameters.Length; i++)
@ -96,5 +98,23 @@ namespace LightweightIocContainer.Registrations
return this; return this;
} }
public IRegistrationBase WithFactory<TFactory>()
{
TypedFactory<TFactory> factory = new(_container);
Factory = factory;
_container.RegisterFactory(factory);
return this;
}
public IRegistrationBase WithFactory<TFactoryInterface, TFactoryImplementation>() where TFactoryImplementation : TFactoryInterface
{
Factory = new CustomTypedFactory();
_container.Register<TFactoryInterface, TFactoryImplementation>();
return this;
}
} }
} }

@ -3,7 +3,7 @@
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
using System; using System;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
@ -14,9 +14,9 @@ namespace LightweightIocContainer.Registrations
/// </summary> /// </summary>
internal class RegistrationFactory internal class RegistrationFactory
{ {
private readonly IIocContainer _iocContainer; private readonly IocContainer _iocContainer;
internal RegistrationFactory(IIocContainer container) => _iocContainer = container; internal RegistrationFactory(IocContainer container) => _iocContainer = container;
/// <summary> /// <summary>
/// Register an Interface with a Type that implements it and create a <see cref="IDefaultRegistration{TInterface,TImplementation}"/> /// Register an Interface with a Type that implements it and create a <see cref="IDefaultRegistration{TInterface,TImplementation}"/>
@ -25,8 +25,8 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam> /// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IDefaultRegistration{TInterface,TImplementation}"/></param> /// <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> /// <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 => public ITypedRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface =>
new DefaultRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), lifestyle); new TypedRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), lifestyle, _iocContainer);
/// <summary> /// <summary>
/// Register an open generic Interface with an open generic Type that implements it and create a <see cref="IOpenGenericRegistration"/> /// Register an open generic Interface with an open generic Type that implements it and create a <see cref="IOpenGenericRegistration"/>
@ -35,7 +35,8 @@ namespace LightweightIocContainer.Registrations
/// <param name="tImplementation">The open generic Type that implements the interface</param> /// <param name="tImplementation">The open generic Type that implements the interface</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IOpenGenericRegistration"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IOpenGenericRegistration"/></param>
/// <returns>The created <see cref="IOpenGenericRegistration"/></returns> /// <returns>The created <see cref="IOpenGenericRegistration"/></returns>
public IOpenGenericRegistration Register(Type tInterface, Type tImplementation, Lifestyle lifestyle) => new OpenGenericRegistration(tInterface, tImplementation, lifestyle); public IOpenGenericRegistration Register(Type tInterface, Type tImplementation, Lifestyle lifestyle) =>
new OpenGenericRegistration(tInterface, tImplementation, lifestyle, _iocContainer);
/// <summary> /// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> /// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2}"/>
@ -46,7 +47,7 @@ namespace LightweightIocContainer.Registrations
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TImplementation> 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 =>
new MultipleRegistration<TInterface1, TInterface2, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle); new MultipleRegistration<TInterface1, TInterface2, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), lifestyle, _iocContainer);
/// <summary> /// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/> /// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/>
@ -58,7 +59,7 @@ namespace LightweightIocContainer.Registrations
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> 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 =>
new MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle); new MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TImplementation), lifestyle, _iocContainer);
/// <summary> /// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/> /// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/>
@ -71,7 +72,7 @@ namespace LightweightIocContainer.Registrations
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param> /// <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> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> 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 =>
new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle); new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TImplementation), lifestyle, _iocContainer);
/// <summary> /// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/> /// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/>
@ -85,7 +86,7 @@ namespace LightweightIocContainer.Registrations
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param> /// <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> /// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> 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 =>
new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle); new MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TInterface3), typeof(TInterface4), typeof(TInterface5), typeof(TImplementation), lifestyle, _iocContainer);
/// <summary> /// <summary>
/// Register a <see cref="Type"/> without an interface and create a <see cref="ISingleTypeRegistration{TInterface}"/> /// Register a <see cref="Type"/> without an interface and create a <see cref="ISingleTypeRegistration{TInterface}"/>
@ -93,7 +94,7 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="T">The <see cref="Type"/> to register</typeparam> /// <typeparam name="T">The <see cref="Type"/> to register</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="ISingleTypeRegistration{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="ISingleTypeRegistration{TInterface}"/></param>
/// <returns>A new created <see cref="ISingleTypeRegistration{TInterface}"/> with the given parameters</returns> /// <returns>A new created <see cref="ISingleTypeRegistration{TInterface}"/> with the given parameters</returns>
public ISingleTypeRegistration<T> Register<T>(Lifestyle lifestyle) => new SingleTypeRegistration<T>(typeof(T), lifestyle); public ISingleTypeRegistration<T> Register<T>(Lifestyle lifestyle) => new SingleTypeRegistration<T>(typeof(T), lifestyle, _iocContainer);
/// <summary> /// <summary>
/// Register an Interface with a Type that implements it as a multiton and create a <see cref="IMultitonRegistration{TInterface,TImplementation}"/> /// Register an Interface with a Type that implements it as a multiton and create a <see cref="IMultitonRegistration{TInterface,TImplementation}"/>
@ -103,7 +104,7 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TScope">The Type of the multiton scope</typeparam> /// <typeparam name="TScope">The Type of the multiton scope</typeparam>
/// <returns>A new created <see cref="IMultitonRegistration{TInterface,TImplementation}"/> with the given parameters</returns> /// <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 => public IMultitonRegistration<TInterface, TImplementation> RegisterMultiton<TInterface, TImplementation, TScope>() where TImplementation : TInterface =>
new MultitonRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), typeof(TScope)); new MultitonRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), typeof(TScope), _iocContainer);
/// <summary> /// <summary>
/// Register multiple interfaces for a <see cref="Type"/> that implements them as a multiton /// Register multiple interfaces for a <see cref="Type"/> that implements them as a multiton
@ -114,13 +115,13 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TScope">The Type of the multiton scope</typeparam> /// <typeparam name="TScope">The Type of the multiton scope</typeparam>
/// <returns>A new created <see cref="IMultipleMultitonRegistration{TInterface1,TInterface2,TImplementation}"/> with the given parameters</returns> /// <returns>A new created <see cref="IMultipleMultitonRegistration{TInterface1,TInterface2,TImplementation}"/> with the given parameters</returns>
public IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> RegisterMultiton<TInterface1, TInterface2, TImplementation, TScope>() where TImplementation : TInterface1, TInterface2 => public IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> RegisterMultiton<TInterface1, TInterface2, TImplementation, TScope>() where TImplementation : TInterface1, TInterface2 =>
new MultipleMultitonRegistration<TInterface1, TInterface2, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), typeof(TScope)); new MultipleMultitonRegistration<TInterface1, TInterface2, TImplementation>(typeof(TInterface1), typeof(TInterface2), typeof(TImplementation), typeof(TScope), _iocContainer);
/// <summary> /// <summary>
/// Register an Interface as an abstract typed factory and create a <see cref="ITypedFactoryRegistration{TFactory}"/> /// Register an Interface as an abstract typed factory and create a <see cref="ITypedFactoryRegistration{TFactory}"/>
/// </summary> /// </summary>
/// <typeparam name="TFactory">The abstract typed factory to register</typeparam> /// <typeparam name="TFactory">The abstract typed factory to register</typeparam>
/// <returns>A new created <see cref="ITypedFactoryRegistration{TFactory}"/> with the given parameters</returns> /// <returns>A new created <see cref="ITypedFactoryRegistration{TFactory}"/> with the given parameters</returns>
public ITypedFactoryRegistration<TFactory> RegisterFactory<TFactory>() => new TypedFactoryRegistration<TFactory>(typeof(TFactory), _iocContainer); public ITypedFactoryRegistration<TFactory> RegisterFactory<TFactory>(ITypedFactory<TFactory> factory) => new TypedFactoryRegistration<TFactory>(factory);
} }
} }

@ -9,19 +9,22 @@ using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations
{ {
/// <summary> /// <summary>
/// The <see cref="IRegistrationBase{TInterface}"/> to register either only an interface or only a <see cref="Type"/> /// The <see cref="IRegistration"/> to register either only an interface or only a <see cref="Type"/>
/// </summary> /// </summary>
/// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistrationBase{TInterface}"/></typeparam> /// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistration"/></typeparam>
public class SingleTypeRegistration<T> : RegistrationBase<T>, ISingleTypeRegistration<T> public class SingleTypeRegistration<T> : RegistrationBase, ISingleTypeRegistration<T>
{ {
/// <summary> /// <summary>
/// The <see cref="IRegistrationBase{TInterface}"/> to register either only an interface or only a <see cref="Type"/> /// The <see cref="IRegistration"/> to register either only an interface or only a <see cref="Type"/>
/// </summary> /// </summary>
/// <param name="interfaceType">The <see cref="Type"/> of the interface or <see cref="Type"/></param> /// <param name="interfaceType">The <see cref="Type"/> of the interface or <see cref="Type"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of the <see cref="RegistrationBase{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> of the <see cref="RegistrationBase"/></param>
public SingleTypeRegistration(Type interfaceType, Lifestyle lifestyle) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType, lifestyle) => public SingleTypeRegistration(Type interfaceType, Lifestyle lifestyle, IocContainer container)
Name = $"{InterfaceType.Name}, Lifestyle: {Lifestyle.ToString()}"; : base(interfaceType, lifestyle, container)
{
}
/// <summary> /// <summary>
/// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way /// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way
@ -32,7 +35,7 @@ namespace LightweightIocContainer.Registrations
/// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way /// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way
/// </summary> /// </summary>
/// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param> /// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param>
/// <returns>The current instance of this <see cref="IRegistrationBase{TInterface}"/></returns> /// <returns>The current instance of this <see cref="IRegistration"/></returns>
public ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocContainer, T> factoryMethod) public ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocContainer, T> factoryMethod)
{ {
FactoryMethod = factoryMethod; FactoryMethod = factoryMethod;

@ -3,13 +3,6 @@
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Factories;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
@ -21,150 +14,20 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TFactory">The <see cref="Type"/> of the abstract typed factory</typeparam> /// <typeparam name="TFactory">The <see cref="Type"/> of the abstract typed factory</typeparam>
public class TypedFactoryRegistration<TFactory> : ITypedFactoryRegistration<TFactory> public class TypedFactoryRegistration<TFactory> : ITypedFactoryRegistration<TFactory>
{ {
private const string CLEAR_MULTITON_INSTANCE_METHOD_NAME = "ClearMultitonInstance";
/// <summary> /// <summary>
/// The registration that is used to register an abstract typed factory /// The registration that is used to register an abstract typed factory
/// </summary> /// </summary>
/// <param name="factoryType">The <see cref="Type"/> of the abstract typed factory</param> /// <param name="factory">The <see cref="ITypedFactory{TFactory}"/> for this <see cref="IRegistration"/></param>
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param> public TypedFactoryRegistration(ITypedFactory<TFactory> factory) => Factory = factory;
public TypedFactoryRegistration(Type factoryType, IIocContainer container)
{
InterfaceType = factoryType;
Name = $"{InterfaceType.Name}";
CreateFactory(container);
}
/// <summary> /// <summary>
/// The name of the <see cref="TypedFactoryRegistration{TFactory}"/> /// The <see cref="Type"/> of the factory that is registered with this <see cref="IRegistration"/>
/// </summary> /// </summary>
public string Name { get; } public Type InterfaceType => typeof(TFactory);
/// <summary>
/// The <see cref="Type"/> of the abstract typed factory that is registered with this <see cref="TypedFactoryRegistration{TFactory}"/>
/// </summary>
public Type InterfaceType { get; }
/// <summary> /// <summary>
/// The class that contains the implemented abstract factory of this <see cref="TypedFactoryRegistration{TFactory}"/> /// The class that contains the implemented abstract factory of this <see cref="TypedFactoryRegistration{TFactory}"/>
/// </summary> /// </summary>
public ITypedFactory<TFactory> Factory { get; private set; } public ITypedFactory<TFactory> Factory { get; }
/// <summary>
/// Creates the factory from the given abstract factory type
/// </summary>
/// <exception cref="InvalidFactoryRegistrationException">Factory registration is invalid</exception>
/// <exception cref="IllegalAbstractMethodCreationException">Creation of abstract methods are illegal in their current state</exception>
private void CreateFactory(IIocContainer container)
{
List<MethodInfo> createMethods = InterfaceType.GetMethods().Where(m => m.ReturnType != typeof(void)).ToList();
if (!createMethods.Any())
throw new InvalidFactoryRegistrationException($"Factory {Name} has no create methods.");
Type type = typeof(TypedFactory<>);
Type factory = type.MakeGenericType(InterfaceType);
Factory = (ITypedFactory<TFactory>) Activator.CreateInstance(factory);
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Factory"), AssemblyBuilderAccess.Run);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("Factory");
TypeBuilder typeBuilder = moduleBuilder.DefineType($"TypedFactory.{InterfaceType.Name}");
typeBuilder.AddInterfaceImplementation(InterfaceType);
//add `private readonly IIocContainer _container` field
FieldBuilder containerFieldBuilder = typeBuilder.DefineField("_container", typeof(IIocContainer), FieldAttributes.Private | FieldAttributes.InitOnly);
//add ctor
ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.HasThis, new[] {typeof(IIocContainer)});
ILGenerator constructorGenerator = constructorBuilder.GetILGenerator();
constructorGenerator.Emit(OpCodes.Ldarg_0);
constructorGenerator.Emit(OpCodes.Ldarg_1);
constructorGenerator.Emit(OpCodes.Stfld, containerFieldBuilder); //set `_container` field
constructorGenerator.Emit(OpCodes.Ret);
foreach (MethodInfo createMethod in createMethods)
{
//create a method that looks like this
//public `createMethod.ReturnType` Create(`createMethod.GetParameters()`)
//{
// return IIocContainer.Resolve(`createMethod.ReturnType`, params);
//}
ParameterInfo[] args = createMethod.GetParameters();
MethodBuilder methodBuilder = typeBuilder.DefineMethod(createMethod.Name, MethodAttributes.Public | MethodAttributes.Virtual,
createMethod.ReturnType, (from arg in args select arg.ParameterType).ToArray());
typeBuilder.DefineMethodOverride(methodBuilder, createMethod);
ILGenerator generator = methodBuilder.GetILGenerator();
generator.Emit(OpCodes.Ldarg_0);
generator.Emit(OpCodes.Ldfld, containerFieldBuilder);
if (args.Any())
{
generator.Emit(OpCodes.Ldc_I4_S, args.Length);
generator.Emit(OpCodes.Newarr, typeof(object));
for (int i = 0; i < args.Length; i++)
{
generator.Emit(OpCodes.Dup);
generator.Emit(OpCodes.Ldc_I4_S, i);
generator.Emit(OpCodes.Ldarg_S, i + 1);
generator.Emit(OpCodes.Box, args[i].ParameterType); //Boxing is only needed for simple datatypes, but for now it is not a problem to box everything
generator.Emit(OpCodes.Stelem_Ref);
}
}
else
{
MethodInfo emptyArray = typeof(Array).GetMethod(nameof(Array.Empty))?.MakeGenericMethod(typeof(object));
generator.EmitCall(OpCodes.Call, emptyArray, null);
}
generator.EmitCall(OpCodes.Callvirt, typeof(IIocContainer).GetMethod(nameof(IIocContainer.Resolve), new[] { typeof(object[]) })?.MakeGenericMethod(createMethod.ReturnType), null);
generator.Emit(OpCodes.Castclass, createMethod.ReturnType);
generator.Emit(OpCodes.Ret);
}
//if factory contains a method to clear multiton instances
MethodInfo multitonClearMethod = InterfaceType.GetMethods().FirstOrDefault(m => m.Name.Equals(CLEAR_MULTITON_INSTANCE_METHOD_NAME));
if (multitonClearMethod != null)
{
//create a method that looks like this
//public void ClearMultitonInstance<typeToClear>()
//{
// IIocContainer.ClearMultitonInstances<typeToClear>();
//}
if (multitonClearMethod.IsGenericMethod)
{
Type typeToClear = multitonClearMethod.GetGenericArguments().FirstOrDefault();
if (typeToClear == null)
throw new IllegalAbstractMethodCreationException("No Type to clear specified.", multitonClearMethod);
MethodBuilder multitonClearMethodBuilder = typeBuilder.DefineMethod(multitonClearMethod.Name, MethodAttributes.Public | MethodAttributes.Virtual,
multitonClearMethod.ReturnType, null);
multitonClearMethodBuilder.DefineGenericParameters(typeToClear.Name);
typeBuilder.DefineMethodOverride(multitonClearMethodBuilder, multitonClearMethod);
ILGenerator multitonClearGenerator = multitonClearMethodBuilder.GetILGenerator();
multitonClearGenerator.Emit(OpCodes.Ldarg_0);
multitonClearGenerator.Emit(OpCodes.Ldfld, containerFieldBuilder);
multitonClearGenerator.EmitCall(OpCodes.Callvirt, typeof(IIocContainer).GetMethod(nameof(IIocContainer.ClearMultitonInstances))?.MakeGenericMethod(typeToClear), null);
multitonClearGenerator.Emit(OpCodes.Ret);
}
else
{
throw new IllegalAbstractMethodCreationException("No Type to clear specified.", multitonClearMethod);
}
}
Factory.Factory = (TFactory) Activator.CreateInstance(typeBuilder.CreateTypeInfo().AsType(), container);
}
} }
} }

@ -3,16 +3,17 @@
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
using System; using System;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders; using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations
{ {
/// <summary> /// <summary>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/> /// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
/// </summary> /// </summary>
public abstract class TypedRegistrationBase<TInterface, TImplementation> : RegistrationBase<TInterface>, ITypedRegistrationBase<TInterface, TImplementation> where TImplementation : TInterface public class TypedRegistration<TInterface, TImplementation> : RegistrationBase, ITypedRegistration<TInterface, TImplementation> where TImplementation : TInterface
{ {
/// <summary> /// <summary>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/> /// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
@ -20,8 +21,9 @@ namespace LightweightIocContainer.Registrations
/// <param name="interfaceType">The <see cref="Type"/> of the interface</param> /// <param name="interfaceType">The <see cref="Type"/> of the interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation type</param> /// <param name="implementationType">The <see cref="Type"/> of the implementation type</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="IRegistrationBase{TInterface}"/></param> /// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="IRegistrationBase{TInterface}"/></param>
protected TypedRegistrationBase(Type interfaceType, Type implementationType, Lifestyle lifestyle) /// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
: base(interfaceType, lifestyle) => public TypedRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType, lifestyle, container) =>
ImplementationType = implementationType; ImplementationType = implementationType;
/// <summary> /// <summary>
@ -39,8 +41,8 @@ namespace LightweightIocContainer.Registrations
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public virtual ITypedRegistrationBase<TInterface, TImplementation> OnCreate(Action<TImplementation> action) public virtual ITypedRegistration<TInterface, TImplementation> OnCreate(Action<TImplementation> action)
{ {
OnCreateAction = a => action((TImplementation) a); OnCreateAction = a => action((TImplementation) a);
return this; return this;

@ -0,0 +1,230 @@
// Author: Gockner, Simon
// Created: 2021-11-29
// Copyright(c) 2021 SimonG. All Rights Reserved.
using JetBrains.Annotations;
using LightweightIocContainer;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using NUnit.Framework;
namespace Test.LightweightIocContainer
{
[TestFixture]
public class FluentFactoryRegistrationTest
{
public interface ITest
{
}
private class Test : ITest
{
}
private class TestByte : ITest
{
[UsedImplicitly]
private readonly byte _id;
public TestByte(byte id) => _id = id;
}
[UsedImplicitly]
private class TestConstructor : ITest
{
public TestConstructor(string name, Test test)
{
}
public TestConstructor(Test test, string name = null)
{
}
}
private interface ITestFactoryNoCreate
{
}
private interface ITestFactoryNonGenericClear
{
ITest Create();
void ClearMultitonInstance();
}
[UsedImplicitly]
public interface ITestFactory
{
ITest Create();
ITest Create(string name);
ITest Create(MultitonScope scope);
ITest CreateTest(string name = null);
ITest Create(byte id);
void ClearMultitonInstance<T>();
}
private class TestFactory : ITestFactory
{
public ITest Create() => new Test();
public ITest Create(string name) => throw new System.NotImplementedException();
public ITest Create(MultitonScope scope) => throw new System.NotImplementedException();
public ITest CreateTest(string name = null) => throw new System.NotImplementedException();
public ITest Create(byte id) => throw new System.NotImplementedException();
public void ClearMultitonInstance<T>() => throw new System.NotImplementedException();
}
public class MultitonScope
{
}
private IIocContainer _iocContainer;
[SetUp]
public void SetUp() => _iocContainer = new IocContainer();
[TearDown]
public void TearDown() => _iocContainer.Dispose();
[Test]
public void TestFluentFactoryRegistration()
{
_iocContainer.Register<ITest, Test>().WithFactory<ITestFactory>();
ITestFactory factory = _iocContainer.Resolve<ITestFactory>();
ITest test = _iocContainer.Resolve<ITest>();
Assert.IsInstanceOf<ITestFactory>(factory);
Assert.IsInstanceOf<ITest>(test);
}
[Test]
public void TestFluentFactoryRegistration_CustomFactory()
{
_iocContainer.Register<ITest, Test>().WithFactory<ITestFactory, TestFactory>();
ITestFactory factory = _iocContainer.Resolve<ITestFactory>();
ITest test = _iocContainer.Resolve<ITest>();
Assert.IsInstanceOf<ITestFactory>(factory);
Assert.IsInstanceOf<ITest>(test);
}
[Test]
public void TestRegisterFactoryWithoutCreate() => Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.Register<ITest, Test>().WithFactory<ITestFactoryNoCreate>());
[Test]
public void TestRegisterFactoryClearMultitonsNonGeneric() => Assert.Throws<IllegalAbstractMethodCreationException>(() => _iocContainer.Register<ITest, Test>().WithFactory<ITestFactoryNonGenericClear>());
[Test]
public void TestResolveFromFactory()
{
_iocContainer.Register<ITest, Test>().WithFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create();
Assert.IsInstanceOf<Test>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithParams()
{
_iocContainer.Register<ITest, TestConstructor>().WithFactory<ITestFactory>();
_iocContainer.Register<Test, Test>(); //this registration is abnormal and should only be used in unit tests
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create("Test");
Assert.IsInstanceOf<TestConstructor>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithDefaultParamCreate()
{
_iocContainer.Register<ITest, TestConstructor>().WithFactory<ITestFactory>();
_iocContainer.Register<Test, Test>(); //this registration is abnormal and should only be used in unit tests
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.CreateTest();
Assert.IsInstanceOf<TestConstructor>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithDefaultParamCtor()
{
_iocContainer.Register<ITest, TestConstructor>().WithFactory<ITestFactory>();
_iocContainer.Register<Test, Test>(); //this registration is abnormal and should only be used in unit tests
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create();
Assert.IsInstanceOf<TestConstructor>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithByte()
{
_iocContainer.Register<ITest, TestByte>().WithFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create(1);
Assert.IsInstanceOf<TestByte>(createdTest);
}
[Test]
public void TestResolveMultitonFromFactory()
{
_iocContainer.RegisterMultiton<ITest, Test, MultitonScope>().WithFactory<ITestFactory>();
MultitonScope scope1 = new MultitonScope();
MultitonScope scope2 = new MultitonScope();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest resolvedTest1 = testFactory.Create(scope1);
ITest resolvedTest2 = testFactory.Create(scope1);
ITest resolvedTest3 = testFactory.Create(scope2);
Assert.AreSame(resolvedTest1, resolvedTest2);
Assert.AreNotSame(resolvedTest1, resolvedTest3);
Assert.AreNotSame(resolvedTest2, resolvedTest3);
}
[Test]
public void TestResolveMultitonFromFactoryClearInstances()
{
_iocContainer.RegisterMultiton<ITest, Test, MultitonScope>().WithFactory<ITestFactory>();
MultitonScope scope1 = new MultitonScope();
MultitonScope scope2 = new MultitonScope();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest resolvedTest1 = testFactory.Create(scope1);
ITest resolvedTest2 = testFactory.Create(scope1);
ITest resolvedTest3 = testFactory.Create(scope2);
Assert.AreSame(resolvedTest1, resolvedTest2);
Assert.AreNotSame(resolvedTest1, resolvedTest3);
Assert.AreNotSame(resolvedTest2, resolvedTest3);
testFactory.ClearMultitonInstance<ITest>();
ITest resolvedTest4 = testFactory.Create(scope1);
ITest resolvedTest5 = testFactory.Create(scope2);
Assert.AreNotSame(resolvedTest1, resolvedTest4);
Assert.AreNotSame(resolvedTest2, resolvedTest4);
Assert.AreNotSame(resolvedTest3, resolvedTest5);
}
}
}

@ -11,35 +11,11 @@ namespace Test.LightweightIocContainer
[TestFixture] [TestFixture]
public class IocContainerTest public class IocContainerTest
{ {
public interface ITest private interface ITest
{ {
} }
[UsedImplicitly]
public interface ITestFactory
{
ITest Create();
ITest Create(string name);
ITest Create(MultitonScope scope);
ITest CreateTest(string name = null);
ITest Create(byte id);
void ClearMultitonInstance<T>();
}
private interface ITestFactoryNoCreate
{
}
private interface ITestFactoryNonGenericClear
{
ITest Create();
void ClearMultitonInstance();
}
private interface IFoo private interface IFoo
{ {
@ -92,22 +68,13 @@ namespace Test.LightweightIocContainer
} }
} }
[UsedImplicitly]
private class TestByte : ITest
{
[UsedImplicitly]
private readonly byte _id;
public TestByte(byte id) => _id = id;
}
[UsedImplicitly] [UsedImplicitly]
private class Foo : IFoo private class Foo : IFoo
{ {
} }
public class MultitonScope private class MultitonScope
{ {
} }
@ -161,9 +128,6 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestInvalidMultitonRegistration() => Assert.Throws<InvalidRegistrationException>(() => _iocContainer.Register<ITest, Test>(Lifestyle.Multiton)); public void TestInvalidMultitonRegistration() => Assert.Throws<InvalidRegistrationException>(() => _iocContainer.Register<ITest, Test>(Lifestyle.Multiton));
[Test]
public void TestRegisterFactory() => Assert.DoesNotThrow(() => _iocContainer.RegisterFactory<ITestFactory>());
[Test] [Test]
public void TestRegisterMultiple() public void TestRegisterMultiple()
{ {
@ -172,12 +136,6 @@ namespace Test.LightweightIocContainer
Assert.AreEqual(typeof(ITest), exception.Type); Assert.AreEqual(typeof(ITest), exception.Type);
} }
[Test]
public void TestRegisterFactoryWithoutCreate() => Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.RegisterFactory<ITestFactoryNoCreate>());
[Test]
public void TestRegisterFactoryClearMultitonsNonGeneric() => Assert.Throws<IllegalAbstractMethodCreationException>(() => _iocContainer.RegisterFactory<ITestFactoryNonGenericClear>());
[Test] [Test]
public void TestResolveNotRegistered() public void TestResolveNotRegistered()
{ {
@ -323,129 +281,6 @@ namespace Test.LightweightIocContainer
Assert.AreEqual(typeof(TestPrivateConstructor), exception.Type); Assert.AreEqual(typeof(TestPrivateConstructor), exception.Type);
} }
[Test]
public void TestResolveFactory()
{
_iocContainer.Register<ITest, Test>();
_iocContainer.RegisterFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
Assert.IsInstanceOf<ITestFactory>(testFactory);
}
[Test]
public void TestResolveFromFactory()
{
_iocContainer.Register<ITest, Test>();
_iocContainer.RegisterFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create();
Assert.IsInstanceOf<Test>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithParams()
{
_iocContainer.Register<ITest, TestConstructor>();
_iocContainer.Register<Test, Test>(); //this registration is abnormal and should only be used in unit tests
_iocContainer.RegisterFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create("Test");
Assert.IsInstanceOf<TestConstructor>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithDefaultParamCreate()
{
_iocContainer.Register<ITest, TestConstructor>();
_iocContainer.Register<Test, Test>(); //this registration is abnormal and should only be used in unit tests
_iocContainer.RegisterFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.CreateTest();
Assert.IsInstanceOf<TestConstructor>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithDefaultParamCtor()
{
_iocContainer.Register<ITest, TestConstructor>();
_iocContainer.Register<Test, Test>(); //this registration is abnormal and should only be used in unit tests
_iocContainer.RegisterFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create();
Assert.IsInstanceOf<TestConstructor>(createdTest);
}
[Test]
public void TestResolveFromFactoryWithByte()
{
_iocContainer.Register<ITest, TestByte>();
_iocContainer.RegisterFactory<ITestFactory>();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest createdTest = testFactory.Create(1);
Assert.IsInstanceOf<TestByte>(createdTest);
}
[Test]
public void TestResolveMultitonFromFactory()
{
_iocContainer.RegisterMultiton<ITest, Test, MultitonScope>();
_iocContainer.RegisterFactory<ITestFactory>();
MultitonScope scope1 = new MultitonScope();
MultitonScope scope2 = new MultitonScope();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest resolvedTest1 = testFactory.Create(scope1);
ITest resolvedTest2 = testFactory.Create(scope1);
ITest resolvedTest3 = testFactory.Create(scope2);
Assert.AreSame(resolvedTest1, resolvedTest2);
Assert.AreNotSame(resolvedTest1, resolvedTest3);
Assert.AreNotSame(resolvedTest2, resolvedTest3);
}
[Test]
public void TestResolveMultitonFromFactoryClearInstances()
{
_iocContainer.RegisterMultiton<ITest, Test, MultitonScope>();
_iocContainer.RegisterFactory<ITestFactory>();
MultitonScope scope1 = new MultitonScope();
MultitonScope scope2 = new MultitonScope();
ITestFactory testFactory = _iocContainer.Resolve<ITestFactory>();
ITest resolvedTest1 = testFactory.Create(scope1);
ITest resolvedTest2 = testFactory.Create(scope1);
ITest resolvedTest3 = testFactory.Create(scope2);
Assert.AreSame(resolvedTest1, resolvedTest2);
Assert.AreNotSame(resolvedTest1, resolvedTest3);
Assert.AreNotSame(resolvedTest2, resolvedTest3);
testFactory.ClearMultitonInstance<ITest>();
ITest resolvedTest4 = testFactory.Create(scope1);
ITest resolvedTest5 = testFactory.Create(scope2);
Assert.AreNotSame(resolvedTest1, resolvedTest4);
Assert.AreNotSame(resolvedTest2, resolvedTest4);
Assert.AreNotSame(resolvedTest3, resolvedTest5);
}
[Test] [Test]
public void TestResolveSingleTypeRegistrationWithFactoryMethod() public void TestResolveSingleTypeRegistrationWithFactoryMethod()
{ {

@ -29,8 +29,8 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestOnCreate() public void TestOnCreate()
{ {
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object); RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IocContainer>().Object);
ITypedRegistrationBase<ITest, Test> testRegistration = registrationFactory.Register<ITest, Test>(Lifestyle.Transient).OnCreate(t => t.DoSomething()); ITypedRegistration<ITest, Test> testRegistration = registrationFactory.Register<ITest, Test>(Lifestyle.Transient).OnCreate(t => t.DoSomething());
Test test = new Test(); Test test = new Test();

@ -5,7 +5,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Registrations; using LightweightIocContainer.Registrations;
using Moq; using Moq;
@ -54,12 +53,12 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestWithParameters() public void TestWithParameters()
{ {
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object); RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IocContainer>().Object);
IBar bar = new Bar(); IBar bar = new Bar();
ITest test = new Test(); ITest test = new Test();
IRegistrationBase<IFoo> testRegistration = registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(bar, test); IRegistrationBase testRegistration = registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(bar, test);
Assert.AreEqual(bar, testRegistration.Parameters[0]); Assert.AreEqual(bar, testRegistration.Parameters[0]);
Assert.AreEqual(test, testRegistration.Parameters[1]); Assert.AreEqual(test, testRegistration.Parameters[1]);
@ -68,12 +67,12 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestWithParametersDifferentOrder() public void TestWithParametersDifferentOrder()
{ {
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object); RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IocContainer>().Object);
IBar bar = new Bar(); IBar bar = new Bar();
ITest test = new Test(); ITest test = new Test();
IRegistrationBase<IFoo> testRegistration = registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((0, bar), (3, test), (2, "SomeString")); IRegistrationBase testRegistration = registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((0, bar), (3, test), (2, "SomeString"));
Assert.AreEqual(bar, testRegistration.Parameters[0]); Assert.AreEqual(bar, testRegistration.Parameters[0]);
Assert.IsInstanceOf<InternalResolvePlaceholder>(testRegistration.Parameters[1]); Assert.IsInstanceOf<InternalResolvePlaceholder>(testRegistration.Parameters[1]);
@ -84,7 +83,7 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestWithParametersCalledTwice() public void TestWithParametersCalledTwice()
{ {
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object); RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IocContainer>().Object);
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(new Bar()).WithParameters(new Test())); Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(new Bar()).WithParameters(new Test()));
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((0, new Bar())).WithParameters((1, new Test()))); Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((0, new Bar())).WithParameters((1, new Test())));
} }
@ -92,7 +91,7 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestWithParametersNoParametersGiven() public void TestWithParametersNoParametersGiven()
{ {
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object); RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IocContainer>().Object);
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((object[])null)); Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((object[])null));
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(((int index, object parameter)[])null)); Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(((int index, object parameter)[])null));
} }

@ -45,7 +45,7 @@ namespace Test.LightweightIocContainer
{ {
IBar bar = new Bar(); IBar bar = new Bar();
Mock<IIocContainer> iocContainerMock = new Mock<IIocContainer>(); Mock<IocContainer> iocContainerMock = new();
iocContainerMock.Setup(c => c.Resolve<IBar>()).Returns(bar); iocContainerMock.Setup(c => c.Resolve<IBar>()).Returns(bar);
RegistrationFactory registrationFactory = new RegistrationFactory(iocContainerMock.Object); RegistrationFactory registrationFactory = new RegistrationFactory(iocContainerMock.Object);

Loading…
Cancel
Save