#50: append factory registration
pull/57/head
Simon G 4 years ago committed by GitHub
commit 7d849f5de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      LightweightIocContainer/Factories/CustomTypedFactory.cs
  2. 125
      LightweightIocContainer/Factories/TypedFactory.cs
  3. 36
      LightweightIocContainer/Factories/TypedFactoryBase.cs
  4. 16
      LightweightIocContainer/Interfaces/Factories/ITypedFactory.cs
  5. 26
      LightweightIocContainer/Interfaces/IIocContainer.cs
  6. 8
      LightweightIocContainer/Interfaces/Registrations/Fluent/IOnCreate.cs
  7. 34
      LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs
  8. 15
      LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs
  9. 18
      LightweightIocContainer/Interfaces/Registrations/IDefaultRegistration.cs
  10. 2
      LightweightIocContainer/Interfaces/Registrations/IMultipleMultitonRegistration.cs
  11. 10
      LightweightIocContainer/Interfaces/Registrations/IMultipleRegistration.cs
  12. 14
      LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
  13. 9
      LightweightIocContainer/Interfaces/Registrations/IOpenGenericRegistration.cs
  14. 5
      LightweightIocContainer/Interfaces/Registrations/IRegistration.cs
  15. 15
      LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs
  16. 8
      LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs
  17. 28
      LightweightIocContainer/Interfaces/Registrations/ITypedRegistration.cs
  18. 36
      LightweightIocContainer/Interfaces/Registrations/ITypedRegistrationBase.cs
  19. 81
      LightweightIocContainer/IocContainer.cs
  20. 2
      LightweightIocContainer/Lifestyle.cs
  21. 412
      LightweightIocContainer/LightweightIocContainer.xml
  22. 27
      LightweightIocContainer/Registrations/DefaultRegistration.cs
  23. 18
      LightweightIocContainer/Registrations/MultipleMultitonRegistration.cs
  24. 124
      LightweightIocContainer/Registrations/MultipleRegistration.cs
  25. 8
      LightweightIocContainer/Registrations/MultitonRegistration.cs
  26. 28
      LightweightIocContainer/Registrations/OpenGenericRegistration.cs
  27. 68
      LightweightIocContainer/Registrations/RegistrationBase.cs
  28. 43
      LightweightIocContainer/Registrations/RegistrationFactory.cs
  29. 21
      LightweightIocContainer/Registrations/SingleTypeRegistration.cs
  30. 147
      LightweightIocContainer/Registrations/TypedFactoryRegistration.cs
  31. 22
      LightweightIocContainer/Registrations/TypedRegistration.cs
  32. 230
      Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs
  33. 169
      Test.LightweightIocContainer/IocContainerTest.cs
  34. 4
      Test.LightweightIocContainer/OnCreateTest.cs
  35. 13
      Test.LightweightIocContainer/RegistrationBaseTest.cs
  36. 2
      Test.LightweightIocContainer/SingleTypeRegistrationTest.cs

@ -0,0 +1,16 @@
// Author: Gockner, Simon
// Created: 2021-12-01
// Copyright(c) 2021 SimonG. All Rights Reserved.
using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Factories
{
/// <summary>
/// <see cref="ITypedFactory"/> implementation for custom implemented factories
/// </summary>
public class CustomTypedFactory<TFactory> : TypedFactoryBase<TFactory>
{
}
}

@ -2,6 +2,13 @@
// Created: 2019-05-20
// 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;
namespace LightweightIocContainer.Factories
@ -10,11 +17,127 @@ namespace LightweightIocContainer.Factories
/// Class to help implement an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The type of the abstract factory</typeparam>
public class TypedFactory<TFactory> : ITypedFactory<TFactory>
public class TypedFactory<TFactory> : TypedFactoryBase<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>
/// The implemented abstract typed factory/>
/// </summary>
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);
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);
}
}
}

@ -0,0 +1,36 @@
// Author: Gockner, Simon
// Created: 2021-12-03
// Copyright(c) 2021 SimonG. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Factories
{
/// <summary>
/// Base class for the <see cref="ITypedFactory"/>
/// </summary>
public abstract class TypedFactoryBase<TFactory> : ITypedFactory
{
/// <summary>
/// The create methods of this <see cref="ITypedFactory"/>
/// </summary>
public List<MethodInfo> CreateMethods
{
get
{
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.");
return createMethods;
}
}
}
}

@ -2,13 +2,27 @@
// Created: 2019-05-20
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System.Collections.Generic;
using System.Reflection;
namespace LightweightIocContainer.Interfaces.Factories
{
/// <summary>
/// Non-generic <see cref="ITypedFactory{TFactory}"/>
/// </summary>
public interface ITypedFactory
{
/// <summary>
/// The create methods of this <see cref="ITypedFactory"/>
/// </summary>
List<MethodInfo> CreateMethods { get; }
}
/// <summary>
/// Class to help implement an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The type of the abstract factory</typeparam>
public interface ITypedFactory<TFactory>
public interface ITypedFactory<TFactory> : ITypedFactory
{
/// <summary>
/// The implemented abstract typed factory

@ -25,18 +25,19 @@ namespace LightweightIocContainer.Interfaces
/// </summary>
/// <typeparam name="TInterface">The Interface to register</typeparam>
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <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>
/// Register an open generic Interface with an open generic Type that implements it
/// </summary>
/// <param name="tInterface">The open generic Interface to register</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>
IOpenGenericRegistration RegisterOpenGenerics(Type tInterface, Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient);
IOpenGenericRegistration RegisterOpenGenerics(Type tInterface, Type tImplementation,
Lifestyle lifestyle = Lifestyle.Transient);
/// <summary>
/// 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="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <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;
@ -55,7 +56,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <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;
@ -67,7 +68,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistration"/></param>
/// <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;
@ -80,7 +81,7 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TInterface5">A fifth interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <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>
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
/// </summary>
/// <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>
ISingleTypeRegistration<TImplementation> Register<TImplementation>(Lifestyle lifestyle = Lifestyle.Transient);
@ -111,13 +112,6 @@ namespace LightweightIocContainer.Interfaces
/// <returns>The created <see cref="IRegistration"/></returns>
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>
/// Gets an instance of the given <see cref="Type"/>
/// </summary>

@ -5,7 +5,7 @@
using System;
using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
namespace LightweightIocContainer.Interfaces.Registrations.Fluent
{
/// <summary>
/// Provides an <see cref="OnCreateAction"/> to the generic <see cref="IOnCreate{TInterface, TImplementation}"/>
@ -20,7 +20,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
}
/// <summary>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IRegistrationBase{TInterface}"/>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IRegistrationBase"/>
/// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam>
@ -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
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
ITypedRegistrationBase<TInterface, TImplementation> OnCreate(Action<TImplementation> action);
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
ITypedRegistration<TInterface, TImplementation> OnCreate(Action<TImplementation> action);
}
}

@ -0,0 +1,34 @@
// Author: Gockner, Simon
// Created: 2021-11-30
// Copyright(c) 2021 SimonG. All Rights Reserved.
using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Interfaces.Registrations.Fluent
{
/// <summary>
/// Provides a <see cref="WithFactory{TFactory}"/> method to an <see cref="IRegistrationBase"/>
/// </summary>
public interface IWithFactory
{
/// <summary>
/// The Factory added with the <see cref="WithFactory{TFactory}"/> method
/// </summary>
ITypedFactory Factory { get; }
/// <summary>
/// Register an abstract typed factory for the <see cref="IRegistrationBase"/>
/// </summary>
/// <typeparam name="TFactory">The type of the abstract typed factory</typeparam>
/// <returns>The current instance of this <see cref="IRegistrationBase"/></returns>
IRegistrationBase WithFactory<TFactory>();
/// <summary>
/// Register a custom implemented factory for the <see cref="IRegistrationBase"/>
/// </summary>
/// <typeparam name="TFactoryInterface">The type of the interface for the custom factory</typeparam>
/// <typeparam name="TFactoryImplementation">The type of the implementation for the custom factory</typeparam>
/// <returns>The current instance of this <see cref="IRegistrationBase"/></returns>
IRegistrationBase WithFactory<TFactoryInterface, TFactoryImplementation>() where TFactoryImplementation : TFactoryInterface;
}
}

@ -6,13 +6,12 @@ using System;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
namespace LightweightIocContainer.Interfaces.Registrations.Fluent
{
/// <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>
/// <typeparam name="TInterface">The registered interface</typeparam>
public interface IWithParameters<TInterface>
public interface IWithParameters
{
/// <summary>
/// An <see cref="Array"/> of parameters that are used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
@ -25,17 +24,17 @@ namespace LightweightIocContainer.Interfaces.Registrations.FluentProviders
/// <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>
/// <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"/></returns>
/// <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>
/// 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 inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving</para>
/// </summary>
/// <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"/></returns>
/// <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
{
/// <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>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>

@ -11,7 +11,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// </summary>
/// <typeparam name="TInterface1">The first interface</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>
/// 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>
/// 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>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
@ -31,7 +31,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
}
/// <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>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
@ -43,7 +43,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
}
/// <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>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
@ -56,7 +56,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
}
/// <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>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>

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

@ -2,18 +2,13 @@
// Created: 2020-09-18
// Copyright(c) 2020 SimonG. All Rights Reserved.
using System;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// <see cref="IRegistration"/> for open generic types
/// </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>
public interface IRegistration
{
/// <summary>
/// The name of the <see cref="IRegistration"/>
/// </summary>
string Name { get; }
/// <summary>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="IRegistration"/>
/// </summary>

@ -2,23 +2,14 @@
// Created: 2019-05-20
// Copyright(c) 2019 SimonG. All Rights Reserved.
using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <summary>
/// A base <see cref="IRegistrationBase"/> without generic interface
/// The <see cref="IRegistrationBase"/> that is used to register an Interface and extends the <see cref="IRegistration"/> with fluent options
/// </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>
public interface IRegistrationBase : IRegistration, IWithFactory, IWithParameters, ILifestyleProvider
{
}

@ -7,10 +7,10 @@ using System;
namespace LightweightIocContainer.Interfaces.Registrations
{
/// <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>
/// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistrationBase{TInterface}"/></typeparam>
public interface ISingleTypeRegistration<T> : IRegistrationBase<T>
/// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistration"/></typeparam>
public interface ISingleTypeRegistration<T> : IRegistrationBase
{
/// <summary>
/// <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
/// </summary>
/// <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);
}
}

@ -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 LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
using LightweightIocContainer.Interfaces.Registrations.Fluent;
using LightweightIocContainer.Registrations;
namespace LightweightIocContainer
@ -54,11 +55,11 @@ namespace LightweightIocContainer
/// </summary>
/// <typeparam name="TInterface">The Interface to register</typeparam>
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase"/></param>
/// <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);
return registration;
@ -93,7 +94,7 @@ namespace LightweightIocContainer
/// <typeparam name="TInterface1">The base 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>
/// <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"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TImplementation> Register<TInterface1, TInterface2, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface2, TInterface1
{
@ -110,7 +111,7 @@ namespace LightweightIocContainer
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/></returns>
public IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> Register<TInterface1, TInterface2, TInterface3, TImplementation>(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface3, TInterface2, TInterface1
{
@ -129,7 +130,7 @@ namespace LightweightIocContainer
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase"/></param>
/// <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 = Lifestyle.Transient) where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
{
@ -149,7 +150,7 @@ namespace LightweightIocContainer
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TInterface5">A fifth interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase"/></param>
/// <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 = Lifestyle.Transient) where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
{
@ -164,7 +165,7 @@ namespace LightweightIocContainer
/// Register a <see cref="Type"/> without an interface
/// </summary>
/// <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="IRegistrationBase"/></param>
/// <returns>The created <see cref="IRegistration"/></returns>
public ISingleTypeRegistration<TImplementation> Register<TImplementation>(Lifestyle lifestyle = Lifestyle.Transient)
{
@ -210,13 +211,7 @@ namespace LightweightIocContainer
/// </summary>
/// <typeparam name="TFactory">The abstract typed factory to register</typeparam>
/// <returns>The created <see cref="IRegistration"/></returns>
public ITypedFactoryRegistration<TFactory> RegisterFactory<TFactory>()
{
ITypedFactoryRegistration<TFactory> registration = _registrationFactory.RegisterFactory<TFactory>();
Register(registration);
return registration;
}
internal void RegisterFactory<TFactory>(ITypedFactory<TFactory> factory) => Register(_registrationFactory.RegisterFactory(factory));
/// <summary>
/// Add the <see cref="IRegistration"/> to the the <see cref="IocContainer"/>
@ -255,7 +250,7 @@ namespace LightweightIocContainer
/// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <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>
/// Gets an instance of the given <see cref="Type"/>
@ -305,8 +300,8 @@ namespace LightweightIocContainer
{
if (defaultRegistration.Lifestyle == Lifestyle.Singleton)
resolvedInstance = GetOrCreateSingletonInstance<T>(defaultRegistration, arguments, resolveStack);
else if (defaultRegistration is IMultitonRegistration<T> multitonRegistration && defaultRegistration.Lifestyle == Lifestyle.Multiton)
resolvedInstance = GetOrCreateMultitonInstance(multitonRegistration, arguments, resolveStack);
else if (defaultRegistration is IMultitonRegistration multitonRegistration && defaultRegistration.Lifestyle == Lifestyle.Multiton)
resolvedInstance = GetOrCreateMultitonInstance<T>(multitonRegistration, arguments, resolveStack);
else
resolvedInstance = CreateInstance<T>(defaultRegistration, arguments, resolveStack);
}
@ -314,13 +309,6 @@ namespace LightweightIocContainer
{
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
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)
{
Type type;
if (registration is ITypedRegistrationBase<T> typedRegistration)
if (registration is ITypedRegistration typedRegistration)
type = typedRegistration.ImplementationType;
else if (registration is ISingleTypeRegistration<T> singleTypeRegistration)
type = singleTypeRegistration.InterfaceType;
else if (registration is IOpenGenericRegistration openGenericRegistration)
type = openGenericRegistration.ImplementationType;
else
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>
/// <exception cref="MultitonResolveException">No arguments 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())
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>
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);
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);
instance = (T) Activator.CreateInstance(defaultRegistration.ImplementationType, arguments);
@ -435,15 +430,6 @@ namespace LightweightIocContainer
else //factory method set to create the instance
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
throw new UnknownRegistrationException($"There is no registration of type {registration.GetType().Name}.");
@ -454,13 +440,12 @@ namespace LightweightIocContainer
}
/// <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.Parameters"/> of the given <see cref="IRegistrationBase"/>
/// </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"/> of the given <see cref="Type"/></param>
/// <param name="arguments">The constructor arguments</param>
/// <returns>The argument list updated with the <see cref="IWithParameters{TInterface}.Parameters"/></returns>
private object[] UpdateArgumentsWithRegistrationParameters<T>(IWithParameters<T> registration, object[] arguments)
/// <returns>The argument list updated with the <see cref="IWithParameters.Parameters"/></returns>
private object[] UpdateArgumentsWithRegistrationParameters(IWithParameters registration, object[] arguments)
{
if (arguments != null && arguments.Any()) //if more arguments were passed to resolve
{
@ -588,7 +573,7 @@ namespace LightweightIocContainer
if (registration != null)
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)
return registration;
@ -610,7 +595,7 @@ namespace LightweightIocContainer
public void ClearMultitonInstances<T>()
{
IRegistration registration = FindRegistration<T>();
if (!(registration is IMultitonRegistration<T> multitonRegistration))
if (!(registration is IMultitonRegistration multitonRegistration))
return;
var multitonInstance = _multitons.FirstOrDefault(m => m.type == multitonRegistration.ImplementationType);

@ -7,7 +7,7 @@ using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer
{
/// <summary>
/// The Lifestyles that can be used for a <see cref="IRegistrationBase{TInterface}"/>
/// The Lifestyles that can be used for a <see cref="IRegistrationBase"/>
/// </summary>
public enum Lifestyle
{

@ -274,17 +274,35 @@
</summary>
<param name="message">The exception message</param>
</member>
<member name="T:LightweightIocContainer.Factories.CustomTypedFactory">
<summary>
<see cref="T:LightweightIocContainer.Interfaces.Factories.ITypedFactory"/> implementation for custom implemented factories
</summary>
</member>
<member name="T:LightweightIocContainer.Factories.TypedFactory`1">
<summary>
Class to help implement an abstract typed factory
</summary>
<typeparam name="TFactory">The type of the abstract factory</typeparam>
</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">
<summary>
The implemented abstract typed factory/>
</summary>
</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">
<summary>
Helper class to call a generic method without generic type parameters
@ -343,6 +361,11 @@
<param name="assembly">The given <see cref="T:System.Reflection.Assembly"/></param>
<returns>A new <see cref="T:LightweightIocContainer.Interfaces.Installers.IAssemblyInstaller"/> with the given <see cref="T:System.Reflection.Assembly"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Factories.ITypedFactory">
<summary>
Non-generic <see cref="T:LightweightIocContainer.Interfaces.Factories.ITypedFactory`1"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Factories.ITypedFactory`1">
<summary>
Class to help implement an abstract typed factory
@ -372,7 +395,7 @@
</summary>
<typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.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>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.RegisterOpenGenerics(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
@ -381,7 +404,7 @@
</summary>
<param name="tInterface">The open generic Interface to register</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>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``3(LightweightIocContainer.Lifestyle)">
@ -391,7 +414,7 @@
<typeparam name="TInterface1">The base 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>
<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>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``4(LightweightIocContainer.Lifestyle)">
@ -402,7 +425,7 @@
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<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>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``5(LightweightIocContainer.Lifestyle)">
@ -414,7 +437,7 @@
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<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>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``6(LightweightIocContainer.Lifestyle)">
@ -427,7 +450,7 @@
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<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>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Register``1(LightweightIocContainer.Lifestyle)">
@ -435,7 +458,7 @@
Register a <see cref="T:System.Type"/> without an interface
</summary>
<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>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.RegisterMultiton``3">
@ -457,13 +480,6 @@
<typeparam name="TScope">The Type of the multiton scope</typeparam>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</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">
<summary>
Gets an instance of the given <see cref="T:System.Type"/>
@ -513,67 +529,84 @@
</summary>
<param name="container">The current <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate">
<member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate">
<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>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate.OnCreateAction">
<member name="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate.OnCreateAction">
<summary>
This <see cref="T:System.Action"/> is invoked when an instance of this type is created.
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`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>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2">
<member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2">
<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="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
<typeparam name="TInterface">The registered interface</typeparam>
<typeparam name="TImplementation">The registered implementation</typeparam>
</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>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1">
<member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithFactory">
<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.IWithFactory.WithFactory``1"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithFactory.Factory">
<summary>
The Factory added with the <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithFactory.WithFactory``1"/> method
</summary>
<typeparam name="TInterface">The registered interface</typeparam>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters">
<member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithFactory.WithFactory``1">
<summary>
Register an abstract typed factory for the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
<typeparam name="TFactory">The type of the abstract typed factory</typeparam>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithFactory.WithFactory``2">
<summary>
Register a custom implemented factory for the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
<typeparam name="TFactoryInterface">The type of the interface for the custom factory</typeparam>
<typeparam name="TFactoryImplementation">The type of the implementation for the custom factory</typeparam>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters">
<summary>
Provides a <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])"/> method to an <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.Parameters">
<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"/>
<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>
</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>
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>
</summary>
<param name="parameters">The parameters</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns>
<exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters"/> are already set or no parameters given</exception>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></returns>
<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="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>
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>
</summary>
<param name="parameters">The parameters with their position</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns>
<exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters"/> are already set or no parameters given</exception>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`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>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></returns>
<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.ILifestyleProvider">
<summary>
@ -587,7 +620,7 @@
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleMultitonRegistration`3">
<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>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
@ -607,7 +640,7 @@
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
@ -615,7 +648,7 @@
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
@ -624,7 +657,7 @@
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
@ -634,7 +667,7 @@
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`6">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
@ -645,15 +678,10 @@
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration">
<summary>
Non generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"/>
Non generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1">
<summary>
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1"/> without implementation
</summary>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration`1.Scope">
<member name="P:LightweightIocContainer.Interfaces.Registrations.IMultitonRegistration.Scope">
<summary>
The <see cref="T:System.Type"/> of the multiton scope
</summary>
@ -670,21 +698,11 @@
<see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types
</summary>
</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">
<summary>
The base registration that is used to register an Interface
</summary>
</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">
<summary>
The <see cref="T:System.Type"/> of the Interface that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
@ -692,20 +710,14 @@
</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
The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/> that is used to register an Interface and extends the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> with fluent options
</summary>
<typeparam name="TInterface">The registered Interface</typeparam>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1">
<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>
<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 name="P:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1.FactoryMethod">
<summary>
@ -717,7 +729,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
</summary>
<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 name="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1">
<summary>
@ -730,24 +742,19 @@
The class that contains the implemented abstract factory of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1"/>
</summary>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase">
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration">
<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>
</member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase.ImplementationType">
<member name="P:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration.ImplementationType">
<summary>
The <see cref="T:System.Type"/> that implements the <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
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>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`1">
<member name="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2">
<summary>
A base <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`1"/> without generic implementation
</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"/>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> that implements a <see cref="T:System.Type"/>
</summary>
</member>
<member name="T:LightweightIocContainer.InternalResolvePlaceholder">
@ -778,7 +785,7 @@
</summary>
<typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.RegisterOpenGenerics(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
@ -799,7 +806,7 @@
<typeparam name="TInterface1">The base 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>
<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.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``4(LightweightIocContainer.Lifestyle)">
@ -810,7 +817,7 @@
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``5(LightweightIocContainer.Lifestyle)">
@ -822,7 +829,7 @@
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``6(LightweightIocContainer.Lifestyle)">
@ -835,7 +842,7 @@
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.Register``1(LightweightIocContainer.Lifestyle)">
@ -843,7 +850,7 @@
Register a <see cref="T:System.Type"/> without an interface
</summary>
<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.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.RegisterMultiton``3">
@ -865,7 +872,7 @@
<typeparam name="TScope">The Type of the multiton scope</typeparam>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.RegisterFactory``1">
<member name="M:LightweightIocContainer.IocContainer.RegisterFactory``1(LightweightIocContainer.Interfaces.Factories.ITypedFactory{``0})">
<summary>
Register an Interface as an abstract typed factory
</summary>
@ -933,7 +940,7 @@
<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>
</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>
Gets or creates a multiton instance of a given <see cref="T:System.Type"/>
</summary>
@ -955,14 +962,13 @@
<param name="resolveStack">The current resolve stack</param>
<returns>A newly created instance of the given <see cref="T:System.Type"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.UpdateArgumentsWithRegistrationParameters``1(LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters{``0},System.Object[])">
<member name="M:LightweightIocContainer.IocContainer.UpdateArgumentsWithRegistrationParameters(LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters,System.Object[])">
<summary>
Update the given arguments with the <see cref="P:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IWithParameters`1.Parameters"/> of the given <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
Update the given arguments with the <see cref="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.Parameters"/> of the given <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam>
<param name="registration">The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> of the given <see cref="T:System.Type"/></param>
<param name="registration">The <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/> of the given <see cref="T:System.Type"/></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="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.Parameters"/></returns>
</member>
<member name="M:LightweightIocContainer.IocContainer.ResolveConstructorArguments(System.Type,System.Object[],System.Collections.Generic.List{System.Type})">
<summary>
@ -994,7 +1000,7 @@
</member>
<member name="T:LightweightIocContainer.Lifestyle">
<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="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
</member>
<member name="F:LightweightIocContainer.Lifestyle.Transient">
@ -1012,37 +1018,23 @@
A new instance gets created if the given scope has no created instance yet. Otherwise the already created instance is used.
</summary>
</member>
<member name="T:LightweightIocContainer.Registrations.DefaultRegistration`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">
<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.IRegistrationBase"/> to register multiple interfaces for on implementation type that implements them as a multiton
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.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>
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.IRegistrationBase"/> to register multiple interfaces for on implementation type that implements them as a multiton
</summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param>
<param name="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
<param name="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="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.MultipleMultitonRegistration`3.Registrations">
<summary>
@ -1054,7 +1046,7 @@
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`2">
<summary>
@ -1063,13 +1055,14 @@
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</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>
The base class for every <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/> to register multiple interfaces
</summary>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param>
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.MultipleRegistration`2.Registrations">
<summary>
@ -1078,57 +1071,59 @@
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`3">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`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>
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>
<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="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="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`3.OnCreate(System.Action{`2})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`4">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
<typeparam name="TInterface3">The third interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`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>
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>
<param name="interfaceType1">The <see cref="T:System.Type"/> of the first interface</param>
<param name="interfaceType2">The <see cref="T:System.Type"/> of the second interface</param>
<param name="interfaceType3">The <see cref="T:System.Type"/> of the third interface</param>
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`4.OnCreate(System.Action{`3})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`5">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
@ -1136,9 +1131,9 @@
<typeparam name="TInterface4">The fourth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.#ctor(System.Type,System.Type,System.Type,System.Type,System.Type,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>
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>
<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>
@ -1146,17 +1141,18 @@
<param name="interfaceType4">The <see cref="T:System.Type"/> of the fourth interface</param>
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`5.OnCreate(System.Action{`4})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultipleRegistration`6">
<summary>
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> to register multiple interfaces for on implementation type
An <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> to register multiple interfaces for on implementation type
</summary>
<typeparam name="TInterface1">The first interface</typeparam>
<typeparam name="TInterface2">The second interface</typeparam>
@ -1165,9 +1161,9 @@
<typeparam name="TInterface5">The fifth interface</typeparam>
<typeparam name="TImplementation">The implementation</typeparam>
</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>
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>
<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>
@ -1176,13 +1172,14 @@
<param name="interfaceType5">The <see cref="T:System.Type"/> of the fifth interface</param>
<param name="implementationType">The <see cref="T:System.Type"/> of the implementation</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Registrations.MultipleRegistration`2"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="M:LightweightIocContainer.Registrations.MultipleRegistration`6.OnCreate(System.Action{`5})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.MultitonRegistration`2">
<summary>
@ -1191,13 +1188,14 @@
<typeparam name="TInterface">The registered interface</typeparam>
<typeparam name="TImplementation">The registered implementation</typeparam>
</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>
The registration that is used to register a multiton
</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="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 name="P:LightweightIocContainer.Registrations.MultitonRegistration`2.Scope">
<summary>
@ -1209,85 +1207,86 @@
<see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types
</summary>
</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>
<see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/> for open generic types
</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 type</param>
<param name="lifestyle">The <see cref="P:LightweightIocContainer.Registrations.OpenGenericRegistration.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IOpenGenericRegistration"/></param>
</member>
<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>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IOpenGenericRegistration"/></param>
<param name="iocContainer">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.OpenGenericRegistration.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="P:LightweightIocContainer.Registrations.OpenGenericRegistration.Lifestyle">
<member name="T:LightweightIocContainer.Registrations.RegistrationBase">
<summary>
The Lifestyle of Instances that are created with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>
</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
The <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/> that is used to register an Interface
</summary>
<typeparam name="TInterface">The registered Interface</typeparam>
</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>
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>
<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="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</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"/>
The <see cref="T:System.Type"/> of the Interface that is registered with this <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase`1.InterfaceType">
<member name="P:LightweightIocContainer.Registrations.RegistrationBase.Lifestyle">
<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:LightweightIocContainer.Lifestyle"/> of Instances that are created with this <see cref="T:LightweightIocContainer.Registrations.RegistrationBase"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase`1.Lifestyle">
<member name="P:LightweightIocContainer.Registrations.RegistrationBase.Parameters">
<summary>
The <see cref="T:LightweightIocContainer.Lifestyle"/> of Instances that are created with this <see cref="T:LightweightIocContainer.Registrations.RegistrationBase`1"/>
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.WithParameters(System.Object[])"/></para>
</summary>
</member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase`1.Parameters">
<member name="P:LightweightIocContainer.Registrations.RegistrationBase.Factory">
<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"/>
<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>
The Factory added with the <see cref="M:LightweightIocContainer.Registrations.RegistrationBase.WithFactory``1"/> method
</summary>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase`1.WithParameters(System.Object[])">
<member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.Object[])">
<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"/>
<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>
<param name="parameters">The parameters</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns>
<exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Registrations.RegistrationBase`1.Parameters"/> are already set or no parameters given</exception>
<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.Parameters"/> are already set or no parameters given</exception>
</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>
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>
</summary>
<param name="parameters">The parameters with their position</param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></returns>
<exception cref="T:LightweightIocContainer.Exceptions.InvalidRegistrationException"><see cref="P:LightweightIocContainer.Registrations.RegistrationBase`1.Parameters"/> are already set or no parameters given</exception>
<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.Parameters"/> are already set or no parameters given</exception>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithFactory``1">
<summary>
Register an abstract typed factory for the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
<typeparam name="TFactory">The type of the abstract typed factory</typeparam>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithFactory``2">
<summary>
Register a custom implemented factory for the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/>
</summary>
<typeparam name="TFactoryInterface">The type of the interface for the custom factory</typeparam>
<typeparam name="TFactoryImplementation">The type of the implementation for the custom factory</typeparam>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></returns>
</member>
<member name="T:LightweightIocContainer.Registrations.RegistrationFactory">
<summary>
@ -1296,12 +1295,12 @@
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``2(LightweightIocContainer.Lifestyle)">
<summary>
Register an Interface with a Type that implements it and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/>
Register an Interface with a Type that implements it and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/>
</summary>
<typeparam name="TInterface">The Interface to register</typeparam>
<typeparam name="TImplementation">The Type that implements the interface</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/></param>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IDefaultRegistration`2"/> with the given parameters</returns>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></param>
<returns>A new created <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/> with the given parameters</returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register(System.Type,System.Type,LightweightIocContainer.Lifestyle)">
<summary>
@ -1319,7 +1318,7 @@
<typeparam name="TInterface1">The base 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>
<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.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`2"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``4(LightweightIocContainer.Lifestyle)">
@ -1330,7 +1329,7 @@
<typeparam name="TInterface2">A second interface to register</typeparam>
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`3"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``5(LightweightIocContainer.Lifestyle)">
@ -1342,7 +1341,7 @@
<typeparam name="TInterface3">A third interface to register</typeparam>
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`4"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``6(LightweightIocContainer.Lifestyle)">
@ -1355,7 +1354,7 @@
<typeparam name="TInterface4">A fourth interface to register</typeparam>
<typeparam name="TInterface5">A fifth interface to register</typeparam>
<typeparam name="TImplementation">The <see cref="T:System.Type"/> that implements both interfaces</typeparam>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/></param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IMultipleRegistration`5"/></returns>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.Register``1(LightweightIocContainer.Lifestyle)">
@ -1385,7 +1384,7 @@
<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>
</member>
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.RegisterFactory``1">
<member name="M:LightweightIocContainer.Registrations.RegistrationFactory.RegisterFactory``1(LightweightIocContainer.Interfaces.Factories.ITypedFactory{``0})">
<summary>
Register an Interface as an abstract typed factory and create a <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedFactoryRegistration`1"/>
</summary>
@ -1394,16 +1393,17 @@
</member>
<member name="T:LightweightIocContainer.Registrations.SingleTypeRegistration`1">
<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>
<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 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>
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>
<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 name="P:LightweightIocContainer.Registrations.SingleTypeRegistration`1.FactoryMethod">
<summary>
@ -1415,7 +1415,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
</summary>
<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 name="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1">
<summary>
@ -1423,21 +1423,15 @@
</summary>
<typeparam name="TFactory">The <see cref="T:System.Type"/> of the abstract typed factory</typeparam>
</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>
The registration that is used to register an abstract typed factory
</summary>
<param name="factoryType">The <see cref="T:System.Type"/> of the abstract typed factory</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>
<param name="factory">The <see cref="T:LightweightIocContainer.Interfaces.Factories.ITypedFactory`1"/> for this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.InterfaceType">
<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>
</member>
<member name="P:LightweightIocContainer.Registrations.TypedFactoryRegistration`1.Factory">
@ -1445,43 +1439,37 @@
The class that contains the implemented abstract factory of this <see cref="T:LightweightIocContainer.Registrations.TypedFactoryRegistration`1"/>
</summary>
</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>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/> that implements a <see cref="T:System.Type"/>
</summary>
</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>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/> that implements a <see cref="T:System.Type"/>
A <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/> that implements a <see cref="T:System.Type"/>
</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 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="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase"/></param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member>
<member name="P:LightweightIocContainer.Registrations.TypedRegistrationBase`2.ImplementationType">
<member name="P:LightweightIocContainer.Registrations.TypedRegistration`2.ImplementationType">
<summary>
The <see cref="T:System.Type"/> that implements the <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> that is registered with this <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistrationBase`1"/>
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"/>
</summary>
</member>
<member name="P:LightweightIocContainer.Registrations.TypedRegistrationBase`2.OnCreateAction">
<member name="P:LightweightIocContainer.Registrations.TypedRegistration`2.OnCreateAction">
<summary>
This <see cref="T:System.Action"/> is invoked when an instance of this type is created.
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.FluentProviders.IOnCreate`2.OnCreate(System.Action{`1})"/></para>
<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>
</member>
<member name="M:LightweightIocContainer.Registrations.TypedRegistrationBase`2.OnCreate(System.Action{`1})">
<member name="M:LightweightIocContainer.Registrations.TypedRegistration`2.OnCreate(System.Action{`1})">
<summary>
Pass an <see cref="T:System.Action`1"/> that will be invoked when an instance of this type is created
</summary>
<param name="action">The <see cref="T:System.Action`1"/></param>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistrationBase`2"/></returns>
<returns>The current instance of this <see cref="T:LightweightIocContainer.Interfaces.Registrations.ITypedRegistration`2"/></returns>
</member>
<member name="M:LightweightIocContainer.TypeExtension.GetDefault(System.Type)">
<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,12 +4,13 @@
using System;
using System.Collections.Generic;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type that implements them as a multiton
/// An <see cref="IRegistrationBase"/> to register multiple interfaces for on implementation type that implements them as a multiton
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam>
@ -17,19 +18,20 @@ namespace LightweightIocContainer.Registrations
public class MultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> : MultitonRegistration<TInterface1, TImplementation>, IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{
/// <summary>
/// An <see cref="IRegistrationBase{TInterface}"/> to register multiple interfaces for on implementation type that implements them as a multiton
/// An <see cref="IRegistrationBase"/> to register multiple interfaces for on implementation type that implements them as a multiton
/// </summary>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param>
/// <param name="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="scope">The <see cref="Type"/> of the multiton scope</param>
public MultipleMultitonRegistration(Type interfaceType1, Type interfaceType2, Type implementationType, Type scope)
: base(interfaceType1, implementationType, scope)
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
public MultipleMultitonRegistration(Type interfaceType1, Type interfaceType2, Type implementationType, Type scope, IocContainer container)
: base(interfaceType1, implementationType, scope, container)
{
Registrations = new List<IRegistration>()
{
new MultitonRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, scope),
new MultitonRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, scope)
new MultitonRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, scope, container),
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
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
@ -13,7 +14,7 @@ namespace LightweightIocContainer.Registrations
/// </summary>
/// <typeparam name="TInterface1">The first interface</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>
/// 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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
protected MultipleRegistration(Type interfaceType1, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
protected MultipleRegistration(Type interfaceType1, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType1, implementationType, lifestyle, container)
{
}
@ -34,7 +36,7 @@ namespace LightweightIocContainer.Registrations
}
/// <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>
/// <typeparam name="TInterface1">The first 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
{
/// <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>
/// <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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
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 DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle)
new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
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
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}
@ -78,7 +81,7 @@ namespace LightweightIocContainer.Registrations
}
/// <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>
/// <typeparam name="TInterface1">The first 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
{
/// <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>
/// <param name="interfaceType1">The <see cref="Type"/> of the first interface</param>
/// <param name="interfaceType2">The <see cref="Type"/> of the second interface</param>
/// <param name="interfaceType3">The <see cref="Type"/> of the third interface</param>
/// <param name="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
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 DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle)
new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
new TypedRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle, container),
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
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration)
if (registration is ITypedRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
else if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}
@ -127,7 +131,7 @@ namespace LightweightIocContainer.Registrations
}
/// <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>
/// <typeparam name="TInterface1">The first 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
{
/// <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>
/// <param name="interfaceType1">The <see cref="Type"/> of the first 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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type interfaceType4, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
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 DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle),
new DefaultRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle)
new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
new TypedRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle, container),
new TypedRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle, container),
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
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface4, TImplementation> interface4Registration)
if (registration is ITypedRegistration<TInterface4, TImplementation> interface4Registration)
interface4Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration)
else if (registration is ITypedRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
else if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}
@ -181,7 +186,7 @@ namespace LightweightIocContainer.Registrations
}
/// <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>
/// <typeparam name="TInterface1">The first 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
{
/// <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>
/// <param name="interfaceType1">The <see cref="Type"/> of the first 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="implementationType">The <see cref="Type"/> of the implementation</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="MultipleRegistration{TInterface1,TInterface2}"/></param>
public MultipleRegistration(Type interfaceType1, Type interfaceType2, Type interfaceType3, Type interfaceType4, Type interfaceType5, Type implementationType, Lifestyle lifestyle)
: base(interfaceType1, implementationType, lifestyle)
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
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 DefaultRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle),
new DefaultRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle),
new DefaultRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle),
new DefaultRegistration<TInterface5, TImplementation>(interfaceType5, implementationType, lifestyle)
new TypedRegistration<TInterface1, TImplementation>(interfaceType1, implementationType, lifestyle, container),
new TypedRegistration<TInterface2, TImplementation>(interfaceType2, implementationType, lifestyle, container),
new TypedRegistration<TInterface3, TImplementation>(interfaceType3, implementationType, lifestyle, container),
new TypedRegistration<TInterface4, TImplementation>(interfaceType4, implementationType, lifestyle, container),
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
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public override ITypedRegistrationBase<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public override ITypedRegistration<TInterface1, TImplementation> OnCreate(Action<TImplementation> action)
{
foreach (var registration in Registrations)
{
if (registration is IDefaultRegistration<TInterface5, TImplementation> interface5Registration)
if (registration is ITypedRegistration<TInterface5, TImplementation> interface5Registration)
interface5Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface4, TImplementation> interface4Registration)
else if (registration is ITypedRegistration<TInterface4, TImplementation> interface4Registration)
interface4Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface3, TImplementation> interface3Registration)
else if (registration is ITypedRegistration<TInterface3, TImplementation> interface3Registration)
interface3Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface2, TImplementation> interface2Registration)
else if (registration is ITypedRegistration<TInterface2, TImplementation> interface2Registration)
interface2Registration.OnCreate(action);
else if (registration is IDefaultRegistration<TInterface1, TImplementation> interface1Registration)
else if (registration is ITypedRegistration<TInterface1, TImplementation> interface1Registration)
interface1Registration.OnCreate(action);
}

@ -3,6 +3,7 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
@ -12,7 +13,7 @@ namespace LightweightIocContainer.Registrations
/// </summary>
/// <typeparam name="TInterface">The registered interface</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>
/// 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="implementationType">The <see cref="Type"/> of the Implementation</param>
/// <param name="scope">The <see cref="Type"/> of the Multiton Scope</param>
public MultitonRegistration(Type interfaceType, Type implementationType, Type scope)
: base(interfaceType, implementationType, Lifestyle.Multiton) =>
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
public MultitonRegistration(Type interfaceType, Type implementationType, Type scope, IocContainer container)
: base(interfaceType, implementationType, Lifestyle.Multiton, container) =>
Scope = scope;
/// <summary>

@ -3,6 +3,7 @@
// Copyright(c) 2020 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
@ -10,7 +11,7 @@ namespace LightweightIocContainer.Registrations
/// <summary>
/// <see cref="IRegistration"/> for open generic types
/// </summary>
public class OpenGenericRegistration : IOpenGenericRegistration
public class OpenGenericRegistration : RegistrationBase, IOpenGenericRegistration
{
/// <summary>
/// <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="implementationType">The <see cref="Type"/> of the implementation type</param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="IOpenGenericRegistration"/></param>
public OpenGenericRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle)
{
InterfaceType = interfaceType;
/// <param name="iocContainer">The current instance of the <see cref="IIocContainer"/></param>
public OpenGenericRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle, IocContainer iocContainer)
: base(interfaceType, lifestyle, iocContainer) =>
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>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IOpenGenericRegistration"/>
/// </summary>
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.Linq;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Factories;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations
{
/// <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>
/// <typeparam name="TInterface">The registered Interface</typeparam>
public abstract class RegistrationBase<TInterface> : IRegistrationBase<TInterface>
public abstract class RegistrationBase : IRegistrationBase
{
private readonly IocContainer _container;
/// <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>
/// <param name="interfaceType">The <see cref="Type"/> of the Interface</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;
Lifestyle = lifestyle;
_container = container;
}
/// <summary>
/// The name of the <see cref="RegistrationBase{TInterface}"/>
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="RegistrationBase{TInterface}"/>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="RegistrationBase"/>
/// </summary>
public Type InterfaceType { get; }
/// <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>
public Lifestyle Lifestyle { get; }
@ -49,14 +49,19 @@ namespace LightweightIocContainer.Registrations
/// </summary>
public object[] Parameters { get; private set; }
/// <summary>
/// The Factory added with the <see cref="WithFactory{TFactory}"/> method
/// </summary>
public ITypedFactory Factory { get; private set; }
/// <summary>
/// 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>
/// </summary>
/// <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>
public virtual IRegistrationBase<TInterface> WithParameters(params object[] parameters)
public virtual IRegistrationBase WithParameters(params object[] parameters)
{
if (Parameters != null)
throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType}).");
@ -73,9 +78,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>
/// </summary>
/// <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>
public virtual IRegistrationBase<TInterface> WithParameters(params (int index, object parameter)[] parameters)
public virtual IRegistrationBase WithParameters(params (int index, object parameter)[] parameters)
{
if (Parameters != null)
throw new InvalidRegistrationException($"Don't use `WithParameters()` method twice (Type: {InterfaceType}).");
@ -83,7 +88,7 @@ namespace LightweightIocContainer.Registrations
if (parameters == null || !parameters.Any())
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];
for (int i = 0; i < Parameters.Length; i++)
@ -96,5 +101,34 @@ namespace LightweightIocContainer.Registrations
return this;
}
/// <summary>
/// Register an abstract typed factory for the <see cref="IRegistrationBase"/>
/// </summary>
/// <typeparam name="TFactory">The type of the abstract typed factory</typeparam>
/// <returns>The current instance of this <see cref="IRegistrationBase"/></returns>
public IRegistrationBase WithFactory<TFactory>()
{
TypedFactory<TFactory> factory = new(_container);
Factory = factory;
_container.RegisterFactory(factory);
return this;
}
/// <summary>
/// Register a custom implemented factory for the <see cref="IRegistrationBase"/>
/// </summary>
/// <typeparam name="TFactoryInterface">The type of the interface for the custom factory</typeparam>
/// <typeparam name="TFactoryImplementation">The type of the implementation for the custom factory</typeparam>
/// <returns>The current instance of this <see cref="IRegistrationBase"/></returns>
public IRegistrationBase WithFactory<TFactoryInterface, TFactoryImplementation>() where TFactoryImplementation : TFactoryInterface
{
Factory = new CustomTypedFactory<TFactoryInterface>();
_container.Register<TFactoryInterface, TFactoryImplementation>();
return this;
}
}
}

@ -3,7 +3,7 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
@ -14,19 +14,19 @@ namespace LightweightIocContainer.Registrations
/// </summary>
internal class RegistrationFactory
{
private readonly IIocContainer _iocContainer;
private readonly IocContainer _iocContainer;
internal RegistrationFactory(IIocContainer container) => _iocContainer = container;
internal RegistrationFactory(IocContainer container) => _iocContainer = container;
/// <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="ITypedRegistration{TInterface,TImplementation}"/>
/// </summary>
/// <typeparam name="TInterface">The Interface to register</typeparam>
/// <typeparam name="TImplementation">The Type that implements the interface</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IDefaultRegistration{TInterface,TImplementation}"/></param>
/// <returns>A new created <see cref="IDefaultRegistration{TInterface,TImplementation}"/> with the given parameters</returns>
public IDefaultRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface =>
new DefaultRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), lifestyle);
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="ITypedRegistration{TInterface,TImplementation}"/></param>
/// <returns>A new created <see cref="ITypedRegistration{TInterface,TImplementation}"/> with the given parameters</returns>
public ITypedRegistration<TInterface, TImplementation> Register<TInterface, TImplementation>(Lifestyle lifestyle) where TImplementation : TInterface =>
new TypedRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), lifestyle, _iocContainer);
/// <summary>
/// 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="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IOpenGenericRegistration"/></param>
/// <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>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2}"/>
@ -43,10 +44,10 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TInterface1">The base 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>
/// <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"/></param>
/// <returns>The created <see cref="IMultipleRegistration{TInterface1,TInterface2}"/></returns>
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>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3}"/>
@ -55,10 +56,10 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TInterface2">A second interface to register</typeparam>
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase"/></param>
/// <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 =>
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>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4}"/>
@ -68,10 +69,10 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TInterface3">A third interface to register</typeparam>
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase"/></param>
/// <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 =>
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>
/// Register multiple interfaces for a <see cref="Type"/> that implements them and create a <see cref="IMultipleRegistration{TInterface1,TInterface2,TInterface3,TInterface4,TInterface5}"/>
@ -82,10 +83,10 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TInterface4">A fourth interface to register</typeparam>
/// <typeparam name="TInterface5">A fifth interface to register</typeparam>
/// <typeparam name="TImplementation">The <see cref="Type"/> that implements both interfaces</typeparam>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase{TInterface}"/></param>
/// <param name="lifestyle">The <see cref="Lifestyle"/> for this <see cref="IRegistrationBase"/></param>
/// <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 =>
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>
/// 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>
/// <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>
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>
/// 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>
/// <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 =>
new MultitonRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), typeof(TScope));
new MultitonRegistration<TInterface, TImplementation>(typeof(TInterface), typeof(TImplementation), typeof(TScope), _iocContainer);
/// <summary>
/// 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>
/// <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 =>
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>
/// Register an Interface as an abstract typed factory and create a <see cref="ITypedFactoryRegistration{TFactory}"/>
/// </summary>
/// <typeparam name="TFactory">The abstract typed factory to register</typeparam>
/// <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
{
/// <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>
/// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistrationBase{TInterface}"/></typeparam>
public class SingleTypeRegistration<T> : RegistrationBase<T>, ISingleTypeRegistration<T>
/// <typeparam name="T">The <see cref="Type"/> of the <see cref="IRegistration"/></typeparam>
public class SingleTypeRegistration<T> : RegistrationBase, ISingleTypeRegistration<T>
{
/// <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>
/// <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>
public SingleTypeRegistration(Type interfaceType, Lifestyle lifestyle)
: base(interfaceType, lifestyle) =>
Name = $"{InterfaceType.Name}, Lifestyle: {Lifestyle.ToString()}";
/// <param name="lifestyle">The <see cref="Lifestyle"/> of the <see cref="RegistrationBase"/></param>
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
public SingleTypeRegistration(Type interfaceType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType, lifestyle, container)
{
}
/// <summary>
/// <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
/// </summary>
/// <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)
{
FactoryMethod = factoryMethod;

@ -3,13 +3,6 @@
// 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.Factories;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Registrations;
@ -21,150 +14,20 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TFactory">The <see cref="Type"/> of the abstract typed factory</typeparam>
public class TypedFactoryRegistration<TFactory> : ITypedFactoryRegistration<TFactory>
{
private const string CLEAR_MULTITON_INSTANCE_METHOD_NAME = "ClearMultitonInstance";
/// <summary>
/// The registration that is used to register an abstract typed factory
/// </summary>
/// <param name="factoryType">The <see cref="Type"/> of the abstract typed factory</param>
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
public TypedFactoryRegistration(Type factoryType, IIocContainer container)
{
InterfaceType = factoryType;
Name = $"{InterfaceType.Name}";
CreateFactory(container);
}
/// <summary>
/// The name of the <see cref="TypedFactoryRegistration{TFactory}"/>
/// </summary>
public string Name { get; }
/// <param name="factory">The <see cref="ITypedFactory{TFactory}"/> for this <see cref="IRegistration"/></param>
public TypedFactoryRegistration(ITypedFactory<TFactory> factory) => Factory = factory;
/// <summary>
/// The <see cref="Type"/> of the abstract typed factory that is registered with this <see cref="TypedFactoryRegistration{TFactory}"/>
/// The <see cref="Type"/> of the factory that is registered with this <see cref="IRegistration"/>
/// </summary>
public Type InterfaceType { get; }
public Type InterfaceType => typeof(TFactory);
/// <summary>
/// The class that contains the implemented abstract factory of this <see cref="TypedFactoryRegistration{TFactory}"/>
/// </summary>
public ITypedFactory<TFactory> Factory { get; private 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)
{
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);
}
public ITypedFactory<TFactory> Factory { get; }
}
}

@ -3,29 +3,31 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Interfaces.Registrations.FluentProviders;
using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Registrations
{
/// <summary>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
/// A <see cref="IRegistrationBase"/> that implements a <see cref="Type"/>
/// </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>
/// A <see cref="IRegistrationBase{TInterface}"/> that implements a <see cref="Type"/>
/// A <see cref="IRegistrationBase"/> that implements a <see cref="Type"/>
/// </summary>
/// <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="lifestyle">The <see cref="Lifestyle"/> of this <see cref="IRegistrationBase{TInterface}"/></param>
protected TypedRegistrationBase(Type interfaceType, Type implementationType, Lifestyle lifestyle)
: base(interfaceType, lifestyle) =>
/// <param name="lifestyle">The <see cref="Lifestyle"/> of this <see cref="IRegistrationBase"/></param>
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param>
public TypedRegistration(Type interfaceType, Type implementationType, Lifestyle lifestyle, IocContainer container)
: base(interfaceType, lifestyle, container) =>
ImplementationType = implementationType;
/// <summary>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IRegistrationBase{TInterface}"/>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IRegistrationBase"/>
/// </summary>
public Type ImplementationType { get; }
@ -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
/// </summary>
/// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistrationBase{TInterface,TImplementation}"/></returns>
public virtual ITypedRegistrationBase<TInterface, TImplementation> OnCreate(Action<TImplementation> action)
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
public virtual ITypedRegistration<TInterface, TImplementation> OnCreate(Action<TImplementation> action)
{
OnCreateAction = a => action((TImplementation) a);
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]
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
{
@ -92,22 +68,13 @@ namespace Test.LightweightIocContainer
}
}
[UsedImplicitly]
private class TestByte : ITest
{
[UsedImplicitly]
private readonly byte _id;
public TestByte(byte id) => _id = id;
}
[UsedImplicitly]
private class Foo : IFoo
{
}
public class MultitonScope
private class MultitonScope
{
}
@ -161,9 +128,6 @@ namespace Test.LightweightIocContainer
[Test]
public void TestInvalidMultitonRegistration() => Assert.Throws<InvalidRegistrationException>(() => _iocContainer.Register<ITest, Test>(Lifestyle.Multiton));
[Test]
public void TestRegisterFactory() => Assert.DoesNotThrow(() => _iocContainer.RegisterFactory<ITestFactory>());
[Test]
public void TestRegisterMultiple()
{
@ -172,12 +136,6 @@ namespace Test.LightweightIocContainer
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]
public void TestResolveNotRegistered()
{
@ -323,129 +281,6 @@ namespace Test.LightweightIocContainer
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]
public void TestResolveSingleTypeRegistrationWithFactoryMethod()
{

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

@ -5,7 +5,6 @@
using JetBrains.Annotations;
using LightweightIocContainer;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Registrations;
using Moq;
@ -54,12 +53,12 @@ namespace Test.LightweightIocContainer
[Test]
public void TestWithParameters()
{
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object);
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IocContainer>().Object);
IBar bar = new Bar();
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(test, testRegistration.Parameters[1]);
@ -68,12 +67,12 @@ namespace Test.LightweightIocContainer
[Test]
public void TestWithParametersDifferentOrder()
{
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IIocContainer>().Object);
RegistrationFactory registrationFactory = new RegistrationFactory(new Mock<IocContainer>().Object);
IBar bar = new Bar();
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.IsInstanceOf<InternalResolvePlaceholder>(testRegistration.Parameters[1]);
@ -84,7 +83,7 @@ namespace Test.LightweightIocContainer
[Test]
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((0, new Bar())).WithParameters((1, new Test())));
}
@ -92,7 +91,7 @@ namespace Test.LightweightIocContainer
[Test]
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(((int index, object parameter)[])null));
}

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

Loading…
Cancel
Save