- use file scoped namespaces

pull/59/head
Simon G 3 years ago
parent e5b984a058
commit 430f58e1c4
  1. 7
      LightweightIocContainer/ActionExtension.cs
  2. 7
      LightweightIocContainer/EnumerableExtension.cs
  3. 13
      LightweightIocContainer/Exceptions/CircularDependencyException.cs
  4. 13
      LightweightIocContainer/Exceptions/ConstructorNotMatchingException.cs
  5. 13
      LightweightIocContainer/Exceptions/GenericMethodNotFoundException.cs
  6. 13
      LightweightIocContainer/Exceptions/IllegalAbstractMethodCreationException.cs
  7. 13
      LightweightIocContainer/Exceptions/InternalResolveException.cs
  8. 13
      LightweightIocContainer/Exceptions/InvalidFactoryRegistrationException.cs
  9. 13
      LightweightIocContainer/Exceptions/InvalidRegistrationException.cs
  10. 13
      LightweightIocContainer/Exceptions/IocContainerException.cs
  11. 13
      LightweightIocContainer/Exceptions/MultipleRegistrationException.cs
  12. 13
      LightweightIocContainer/Exceptions/MultitonResolveException.cs
  13. 13
      LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs
  14. 13
      LightweightIocContainer/Exceptions/NoPublicConstructorFoundException.cs
  15. 13
      LightweightIocContainer/Exceptions/TypeNotRegisteredException.cs
  16. 13
      LightweightIocContainer/Exceptions/UnknownRegistrationException.cs
  17. 13
      LightweightIocContainer/Factories/CustomTypedFactory.cs
  18. 15
      LightweightIocContainer/Factories/TypedFactory.cs
  19. 13
      LightweightIocContainer/Factories/TypedFactoryBase.cs
  20. 13
      LightweightIocContainer/GenericMethodCaller.cs
  21. 13
      LightweightIocContainer/Installers/AssemblyInstaller.cs
  22. 13
      LightweightIocContainer/Installers/FromAssembly.cs
  23. 27
      LightweightIocContainer/Interfaces/Factories/ITypedFactory.cs
  24. 13
      LightweightIocContainer/Interfaces/IIocContainer.cs
  25. 13
      LightweightIocContainer/Interfaces/IIocResolver.cs
  26. 13
      LightweightIocContainer/Interfaces/Installers/IAssemblyInstaller.cs
  27. 13
      LightweightIocContainer/Interfaces/Installers/IIocInstaller.cs
  28. 29
      LightweightIocContainer/Interfaces/Registrations/Fluent/IOnCreate.cs
  29. 19
      LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs
  30. 19
      LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs
  31. 13
      LightweightIocContainer/Interfaces/Registrations/ILifestyleProvider.cs
  32. 19
      LightweightIocContainer/Interfaces/Registrations/IMultipleMultitonRegistration.cs
  33. 101
      LightweightIocContainer/Interfaces/Registrations/IMultipleRegistration.cs
  34. 29
      LightweightIocContainer/Interfaces/Registrations/IMultitonRegistration.cs
  35. 13
      LightweightIocContainer/Interfaces/Registrations/IOpenGenericRegistration.cs
  36. 13
      LightweightIocContainer/Interfaces/Registrations/IRegistration.cs
  37. 13
      LightweightIocContainer/Interfaces/Registrations/IRegistrationBase.cs
  38. 15
      LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs
  39. 15
      LightweightIocContainer/Interfaces/Registrations/ITypedFactoryRegistration.cs
  40. 25
      LightweightIocContainer/Interfaces/Registrations/ITypedRegistration.cs
  41. 13
      LightweightIocContainer/IocContainer.cs
  42. 13
      LightweightIocContainer/Lifestyle.cs
  43. 19
      LightweightIocContainer/Registrations/MultipleMultitonRegistration.cs
  44. 101
      LightweightIocContainer/Registrations/MultipleRegistration.cs
  45. 17
      LightweightIocContainer/Registrations/MultitonRegistration.cs
  46. 13
      LightweightIocContainer/Registrations/OpenGenericRegistration.cs
  47. 13
      LightweightIocContainer/Registrations/RegistrationBase.cs
  48. 13
      LightweightIocContainer/Registrations/RegistrationFactory.cs
  49. 15
      LightweightIocContainer/Registrations/SingleTypeRegistration.cs
  50. 15
      LightweightIocContainer/Registrations/TypedFactoryRegistration.cs
  51. 13
      LightweightIocContainer/Registrations/TypedRegistration.cs
  52. 13
      LightweightIocContainer/ResolvePlaceholders/InternalResolvePlaceholder.cs
  53. 13
      LightweightIocContainer/ResolvePlaceholders/InternalToBeResolvedPlaceholder.cs
  54. 7
      LightweightIocContainer/TypeExtension.cs
  55. 13
      LightweightIocContainer/Validation/IocValidator.cs
  56. 9
      Test.LightweightIocContainer/ActionExtensionTest.cs
  57. 9
      Test.LightweightIocContainer/AssemblyInstallerTest.cs
  58. 9
      Test.LightweightIocContainer/EnumerableExtensionTest.cs
  59. 9
      Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs
  60. 9
      Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs
  61. 11
      Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs
  62. 9
      Test.LightweightIocContainer/IocContainerRecursionTest.cs
  63. 9
      Test.LightweightIocContainer/IocContainerTest.cs
  64. 9
      Test.LightweightIocContainer/IocValidatorTest.cs
  65. 9
      Test.LightweightIocContainer/MultipleMultitonRegistrationTest.cs
  66. 9
      Test.LightweightIocContainer/OnCreateTest.cs
  67. 9
      Test.LightweightIocContainer/OpenGenericRegistrationTest.cs
  68. 9
      Test.LightweightIocContainer/RegistrationBaseTest.cs
  69. 11
      Test.LightweightIocContainer/SingleTypeRegistrationTest.cs

@ -4,10 +4,10 @@
using System; using System;
namespace LightweightIocContainer namespace LightweightIocContainer;
internal static class ActionExtension
{ {
internal static class ActionExtension
{
/// <summary> /// <summary>
/// Convert an <see cref="Action{T2}"/> to an <see cref="Action{T1}"/> of an inherited <see cref="Type"/> /// Convert an <see cref="Action{T2}"/> to an <see cref="Action{T1}"/> of an inherited <see cref="Type"/>
/// </summary> /// </summary>
@ -22,5 +22,4 @@ namespace LightweightIocContainer
return t => action(t); return t => action(t);
} }
}
} }

@ -6,10 +6,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace LightweightIocContainer namespace LightweightIocContainer;
internal static class EnumerableExtension
{ {
internal static class EnumerableExtension
{
/// <summary> /// <summary>
/// Returns the first element of a <see cref="IEnumerable{T}"/>, or a new instance of a given <see cref="Type"/> if the <see cref="IEnumerable{T}"/> contains no elements /// Returns the first element of a <see cref="IEnumerable{T}"/>, or a new instance of a given <see cref="Type"/> if the <see cref="IEnumerable{T}"/> contains no elements
/// </summary> /// </summary>
@ -62,5 +62,4 @@ namespace LightweightIocContainer
foreach (T item in enumerable) foreach (T item in enumerable)
action(item); action(item);
} }
}
} }

@ -7,13 +7,13 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// A circular dependency was detected during <see cref="IocContainer.Resolve{T}()"/>
/// </summary>
internal class CircularDependencyException : IocContainerException
{ {
/// <summary>
/// A circular dependency was detected during <see cref="IocContainer.Resolve{T}()"/>
/// </summary>
internal class CircularDependencyException : IocContainerException
{
/// <summary> /// <summary>
/// A circular dependency was detected during <see cref="IocContainer.Resolve{T}()"/> /// A circular dependency was detected during <see cref="IocContainer.Resolve{T}()"/>
/// </summary> /// </summary>
@ -57,5 +57,4 @@ namespace LightweightIocContainer.Exceptions
return message.ToString(); return message.ToString();
} }
} }
}
} }

@ -5,13 +5,13 @@
using System; using System;
using System.Reflection; using System.Reflection;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// The constructor does not match the given or resolvable arguments
/// </summary>
internal class ConstructorNotMatchingException : IocContainerException
{ {
/// <summary>
/// The constructor does not match the given or resolvable arguments
/// </summary>
internal class ConstructorNotMatchingException : IocContainerException
{
/// <summary> /// <summary>
/// The constructor does not match the given or resolvable arguments /// The constructor does not match the given or resolvable arguments
/// </summary> /// </summary>
@ -25,5 +25,4 @@ namespace LightweightIocContainer.Exceptions
/// The constructor that does not match /// The constructor that does not match
/// </summary> /// </summary>
public ConstructorInfo Constructor { get; } public ConstructorInfo Constructor { get; }
}
} }

@ -4,13 +4,13 @@
using System; using System;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// Could not find generic method
/// </summary>
internal class GenericMethodNotFoundException : Exception
{ {
/// <summary>
/// Could not find generic method
/// </summary>
internal class GenericMethodNotFoundException : Exception
{
/// <summary> /// <summary>
/// Could not find generic method /// Could not find generic method
/// </summary> /// </summary>
@ -20,5 +20,4 @@ namespace LightweightIocContainer.Exceptions
{ {
} }
}
} }

@ -4,13 +4,13 @@
using System.Reflection; using System.Reflection;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// The creation of the abstract method is illegal in its current state
/// </summary>
internal class IllegalAbstractMethodCreationException : IocContainerException
{ {
/// <summary>
/// The creation of the abstract method is illegal in its current state
/// </summary>
internal class IllegalAbstractMethodCreationException : IocContainerException
{
/// <summary> /// <summary>
/// The creation of the abstract method is illegal in its current state /// The creation of the abstract method is illegal in its current state
/// </summary> /// </summary>
@ -24,5 +24,4 @@ namespace LightweightIocContainer.Exceptions
/// The Method whose creation is illegal /// The Method whose creation is illegal
/// </summary> /// </summary>
public MethodInfo Method { get; } public MethodInfo Method { get; }
}
} }

@ -4,13 +4,13 @@
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// An internal Error happened while the <see cref="IIocContainer"/> tried to resolve an instance
/// </summary>
internal class InternalResolveException : IocContainerException
{ {
/// <summary>
/// An internal Error happened while the <see cref="IIocContainer"/> tried to resolve an instance
/// </summary>
internal class InternalResolveException : IocContainerException
{
/// <summary> /// <summary>
/// An internal Error happened while the <see cref="IIocContainer"/> tried to resolve an instance /// An internal Error happened while the <see cref="IIocContainer"/> tried to resolve an instance
/// </summary> /// </summary>
@ -20,5 +20,4 @@ namespace LightweightIocContainer.Exceptions
{ {
} }
}
} }

@ -2,13 +2,13 @@
// Created: 2019-05-20 // Created: 2019-05-20
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// The registration of a Factory is not valid
/// </summary>
internal class InvalidFactoryRegistrationException : InvalidRegistrationException
{ {
/// <summary>
/// The registration of a Factory is not valid
/// </summary>
internal class InvalidFactoryRegistrationException : InvalidRegistrationException
{
/// <summary> /// <summary>
/// The registration of a Factory is not valid /// The registration of a Factory is not valid
/// </summary> /// </summary>
@ -18,5 +18,4 @@ namespace LightweightIocContainer.Exceptions
{ {
} }
}
} }

@ -2,13 +2,13 @@
// Created: 2019-05-20 // Created: 2019-05-20
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// The registration is not valid
/// </summary>
internal class InvalidRegistrationException : IocContainerException
{ {
/// <summary>
/// The registration is not valid
/// </summary>
internal class InvalidRegistrationException : IocContainerException
{
/// <summary> /// <summary>
/// The registration is not valid /// The registration is not valid
/// </summary> /// </summary>
@ -18,5 +18,4 @@ namespace LightweightIocContainer.Exceptions
{ {
} }
}
} }

@ -5,13 +5,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/>
/// </summary>
public abstract class IocContainerException : Exception
{ {
/// <summary>
/// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/>
/// </summary>
public abstract class IocContainerException : Exception
{
/// <summary> /// <summary>
/// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/> /// A base <see cref="Exception"/> for the <see cref="LightweightIocContainer"/>
/// </summary> /// </summary>
@ -38,5 +38,4 @@ namespace LightweightIocContainer.Exceptions
/// The inner exceptions of the <see cref="IocContainerException"/> /// The inner exceptions of the <see cref="IocContainerException"/>
/// </summary> /// </summary>
public List<Exception> InnerExceptions { get; protected init; } public List<Exception> InnerExceptions { get; protected init; }
}
} }

@ -5,13 +5,13 @@
using System; using System;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// The <see cref="System.Type"/> is already registered differently in this <see cref="IIocContainer"/>
/// </summary>
internal class MultipleRegistrationException : IocContainerException
{ {
/// <summary>
/// The <see cref="System.Type"/> is already registered differently in this <see cref="IIocContainer"/>
/// </summary>
internal class MultipleRegistrationException : IocContainerException
{
/// <summary> /// <summary>
/// The <see cref="System.Type"/> is already registered differently in this <see cref="IIocContainer"/> /// The <see cref="System.Type"/> is already registered differently in this <see cref="IIocContainer"/>
/// </summary> /// </summary>
@ -24,5 +24,4 @@ namespace LightweightIocContainer.Exceptions
/// The registered <see cref="System.Type"/> /// The registered <see cref="System.Type"/>
/// </summary> /// </summary>
public Type Type { get; } public Type Type { get; }
}
} }

@ -4,13 +4,13 @@
using System; using System;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// An error happened while trying to resolve a multiton
/// </summary>
internal class MultitonResolveException : InternalResolveException
{ {
/// <summary>
/// An error happened while trying to resolve a multiton
/// </summary>
internal class MultitonResolveException : InternalResolveException
{
/// <summary> /// <summary>
/// An error happened while trying to resolve a multiton /// An error happened while trying to resolve a multiton
/// </summary> /// </summary>
@ -24,5 +24,4 @@ namespace LightweightIocContainer.Exceptions
/// The <see cref="System.Type"/> of the multiton that's responsible for the exception /// The <see cref="System.Type"/> of the multiton that's responsible for the exception
/// </summary> /// </summary>
public Type Type { get; } public Type Type { get; }
}
} }

@ -5,13 +5,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// No matching constructor was found for the given or resolvable arguments
/// </summary>
internal class NoMatchingConstructorFoundException : IocContainerException
{ {
/// <summary>
/// No matching constructor was found for the given or resolvable arguments
/// </summary>
internal class NoMatchingConstructorFoundException : IocContainerException
{
/// <summary> /// <summary>
/// No matching constructor was found for the given or resolvable arguments /// No matching constructor was found for the given or resolvable arguments
/// </summary> /// </summary>
@ -34,5 +34,4 @@ namespace LightweightIocContainer.Exceptions
/// </summary> /// </summary>
/// <param name="exception">The <see cref="ConstructorNotMatchingException"/></param> /// <param name="exception">The <see cref="ConstructorNotMatchingException"/></param>
public void AddInnerException(ConstructorNotMatchingException exception) => InnerExceptions.Add(exception); public void AddInnerException(ConstructorNotMatchingException exception) => InnerExceptions.Add(exception);
}
} }

@ -4,13 +4,13 @@
using System; using System;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// No public constructor can be found for a <see cref="Type"/>
/// </summary>
internal class NoPublicConstructorFoundException : IocContainerException
{ {
/// <summary>
/// No public constructor can be found for a <see cref="Type"/>
/// </summary>
internal class NoPublicConstructorFoundException : IocContainerException
{
/// <summary> /// <summary>
/// No public constructor can be found for a <see cref="Type"/> /// No public constructor can be found for a <see cref="Type"/>
/// </summary> /// </summary>
@ -23,5 +23,4 @@ namespace LightweightIocContainer.Exceptions
/// The <see cref="Type"/> with no public constructor /// The <see cref="Type"/> with no public constructor
/// </summary> /// </summary>
public Type Type { get; } public Type Type { get; }
}
} }

@ -5,13 +5,13 @@
using System; using System;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// The <see cref="System.Type"/> is not registered in this <see cref="IIocContainer"/>
/// </summary>
internal class TypeNotRegisteredException : IocContainerException
{ {
/// <summary>
/// The <see cref="System.Type"/> is not registered in this <see cref="IIocContainer"/>
/// </summary>
internal class TypeNotRegisteredException : IocContainerException
{
/// <summary> /// <summary>
/// The <see cref="System.Type"/> is not registered in this <see cref="IIocContainer"/> /// The <see cref="System.Type"/> is not registered in this <see cref="IIocContainer"/>
/// </summary> /// </summary>
@ -24,5 +24,4 @@ namespace LightweightIocContainer.Exceptions
/// The unregistered <see cref="System.Type"/> /// The unregistered <see cref="System.Type"/>
/// </summary> /// </summary>
public Type Type { get; } public Type Type { get; }
}
} }

@ -4,13 +4,13 @@
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions;
/// <summary>
/// An unknown <see cref="IRegistration"/> was used
/// </summary>
internal class UnknownRegistrationException : IocContainerException
{ {
/// <summary>
/// An unknown <see cref="IRegistration"/> was used
/// </summary>
internal class UnknownRegistrationException : IocContainerException
{
/// <summary> /// <summary>
/// An unknown <see cref="IRegistration"/> was used /// An unknown <see cref="IRegistration"/> was used
/// </summary> /// </summary>
@ -20,5 +20,4 @@ namespace LightweightIocContainer.Exceptions
{ {
} }
}
} }

@ -4,13 +4,12 @@
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Factories namespace LightweightIocContainer.Factories;
/// <summary>
/// <see cref="ITypedFactory"/> implementation for custom implemented factories
/// </summary>
public class CustomTypedFactory<TFactory> : TypedFactoryBase<TFactory>
{ {
/// <summary>
/// <see cref="ITypedFactory"/> implementation for custom implemented factories
/// </summary>
public class CustomTypedFactory<TFactory> : TypedFactoryBase<TFactory>
{
}
} }

@ -10,14 +10,14 @@ using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Factories namespace LightweightIocContainer.Factories;
/// <summary>
/// Class to help implement an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The type of the abstract factory</typeparam>
public class TypedFactory<TFactory> : TypedFactoryBase<TFactory>, ITypedFactory<TFactory>
{ {
/// <summary>
/// Class to help implement an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The type of the abstract factory</typeparam>
public class TypedFactory<TFactory> : TypedFactoryBase<TFactory>, ITypedFactory<TFactory>
{
private const string CLEAR_MULTITON_INSTANCE_METHOD_NAME = "ClearMultitonInstance"; private const string CLEAR_MULTITON_INSTANCE_METHOD_NAME = "ClearMultitonInstance";
/// <summary> /// <summary>
@ -138,5 +138,4 @@ namespace LightweightIocContainer.Factories
return Creator.CreateInstance<TFactory>(typeBuilder.CreateTypeInfo()!.AsType(), container); return Creator.CreateInstance<TFactory>(typeBuilder.CreateTypeInfo()!.AsType(), container);
} }
}
} }

@ -9,13 +9,13 @@ using System.Reflection;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Factories namespace LightweightIocContainer.Factories;
/// <summary>
/// Base class for the <see cref="ITypedFactory"/>
/// </summary>
public abstract class TypedFactoryBase<TFactory> : ITypedFactory
{ {
/// <summary>
/// Base class for the <see cref="ITypedFactory"/>
/// </summary>
public abstract class TypedFactoryBase<TFactory> : ITypedFactory
{
/// <summary> /// <summary>
/// The create methods of this <see cref="ITypedFactory"/> /// The create methods of this <see cref="ITypedFactory"/>
/// </summary> /// </summary>
@ -32,5 +32,4 @@ namespace LightweightIocContainer.Factories
return createMethods; return createMethods;
} }
} }
}
} }

@ -6,13 +6,13 @@ using System;
using System.Reflection; using System.Reflection;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
namespace LightweightIocContainer namespace LightweightIocContainer;
/// <summary>
/// Helper class to call a generic method without generic type parameters
/// </summary>
internal static class GenericMethodCaller
{ {
/// <summary>
/// Helper class to call a generic method without generic type parameters
/// </summary>
internal static class GenericMethodCaller
{
/// <summary> /// <summary>
/// Call a generic method without generic type parameters /// Call a generic method without generic type parameters
/// </summary> /// </summary>
@ -54,5 +54,4 @@ namespace LightweightIocContainer
/// <exception cref="Exception">Any <see cref="Exception"/> thrown after invoking the generic method</exception> /// <exception cref="Exception">Any <see cref="Exception"/> thrown after invoking the generic method</exception>
public static object? CallPrivate(object caller, string functionName, Type genericParameter, params object?[] parameters) => public static object? CallPrivate(object caller, string functionName, Type genericParameter, params object?[] parameters) =>
Call(caller, functionName, genericParameter, BindingFlags.NonPublic | BindingFlags.Instance, parameters); Call(caller, functionName, genericParameter, BindingFlags.NonPublic | BindingFlags.Instance, parameters);
}
} }

@ -9,13 +9,13 @@ using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Installers namespace LightweightIocContainer.Installers;
/// <summary>
/// An <see cref="IIocInstaller"/> that installs all <see cref="IIocInstaller"/>s for its given <see cref="Assembly"/>
/// </summary>
public class AssemblyInstaller : IAssemblyInstaller
{ {
/// <summary>
/// An <see cref="IIocInstaller"/> that installs all <see cref="IIocInstaller"/>s for its given <see cref="Assembly"/>
/// </summary>
public class AssemblyInstaller : IAssemblyInstaller
{
/// <summary> /// <summary>
/// An <see cref="IIocInstaller"/> that installs all <see cref="IIocInstaller"/>s for its given <see cref="Assembly"/> /// An <see cref="IIocInstaller"/> that installs all <see cref="IIocInstaller"/>s for its given <see cref="Assembly"/>
/// </summary> /// </summary>
@ -48,5 +48,4 @@ namespace LightweightIocContainer.Installers
foreach (IIocInstaller installer in Installers) foreach (IIocInstaller installer in Installers)
installer.Install(registration); installer.Install(registration);
} }
}
} }

@ -5,13 +5,13 @@
using System.Reflection; using System.Reflection;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Installers namespace LightweightIocContainer.Installers;
/// <summary>
/// Helper class that supplies methods to find the wanted <see cref="Assembly"/>
/// </summary>
public static class FromAssembly
{ {
/// <summary>
/// Helper class that supplies methods to find the wanted <see cref="Assembly"/>
/// </summary>
public static class FromAssembly
{
/// <summary> /// <summary>
/// Get an <see cref="IAssemblyInstaller"/> that installs from the <see cref="Assembly"/> calling the method /// Get an <see cref="IAssemblyInstaller"/> that installs from the <see cref="Assembly"/> calling the method
/// </summary> /// </summary>
@ -28,5 +28,4 @@ namespace LightweightIocContainer.Installers
/// <param name="assembly">The given <see cref="Assembly"/></param> /// <param name="assembly">The given <see cref="Assembly"/></param>
/// <returns>A new <see cref="IAssemblyInstaller"/> with the given <see cref="Assembly"/></returns> /// <returns>A new <see cref="IAssemblyInstaller"/> with the given <see cref="Assembly"/></returns>
public static IAssemblyInstaller Instance(Assembly assembly) => new AssemblyInstaller(assembly); public static IAssemblyInstaller Instance(Assembly assembly) => new AssemblyInstaller(assembly);
}
} }

@ -5,28 +5,27 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
namespace LightweightIocContainer.Interfaces.Factories namespace LightweightIocContainer.Interfaces.Factories;
/// <summary>
/// Non-generic <see cref="ITypedFactory{TFactory}"/>
/// </summary>
public interface ITypedFactory
{ {
/// <summary>
/// Non-generic <see cref="ITypedFactory{TFactory}"/>
/// </summary>
public interface ITypedFactory
{
/// <summary> /// <summary>
/// The create methods of this <see cref="ITypedFactory"/> /// The create methods of this <see cref="ITypedFactory"/>
/// </summary> /// </summary>
List<MethodInfo> CreateMethods { get; } List<MethodInfo> CreateMethods { get; }
} }
/// <summary> /// <summary>
/// Class to help implement an abstract typed factory /// Class to help implement an abstract typed factory
/// </summary> /// </summary>
/// <typeparam name="TFactory">The type of the abstract factory</typeparam> /// <typeparam name="TFactory">The type of the abstract factory</typeparam>
public interface ITypedFactory<TFactory> : ITypedFactory public interface ITypedFactory<TFactory> : ITypedFactory
{ {
/// <summary> /// <summary>
/// The implemented abstract typed factory /// The implemented abstract typed factory
/// </summary> /// </summary>
TFactory Factory { get; set; } TFactory Factory { get; set; }
}
} }

@ -6,13 +6,13 @@ using System;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Interfaces namespace LightweightIocContainer.Interfaces;
/// <summary>
/// The main container that carries all <see cref="IRegistration"/>s
/// </summary>
public interface IIocContainer : IDisposable
{ {
/// <summary>
/// The main container that carries all <see cref="IRegistration"/>s
/// </summary>
public interface IIocContainer : IDisposable
{
/// <summary> /// <summary>
/// Install the given installers for the current <see cref="IIocContainer"/> /// Install the given installers for the current <see cref="IIocContainer"/>
/// </summary> /// </summary>
@ -38,5 +38,4 @@ namespace LightweightIocContainer.Interfaces
/// <typeparam name="T">The given <see cref="Type"/></typeparam> /// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <returns>True if the given <see cref="Type"/> is registered with this <see cref="IIocContainer"/>, false if not</returns> /// <returns>True if the given <see cref="Type"/> is registered with this <see cref="IIocContainer"/>, false if not</returns>
bool IsTypeRegistered<T>(); bool IsTypeRegistered<T>();
}
} }

@ -4,13 +4,13 @@
using System; using System;
namespace LightweightIocContainer.Interfaces namespace LightweightIocContainer.Interfaces;
/// <summary>
/// Provides <see cref="Resolve{T}()"/> methods
/// </summary>
public interface IIocResolver : IDisposable
{ {
/// <summary>
/// Provides <see cref="Resolve{T}()"/> methods
/// </summary>
public interface IIocResolver : IDisposable
{
/// <summary> /// <summary>
/// Gets an instance of the given <see cref="Type"/> /// Gets an instance of the given <see cref="Type"/>
/// </summary> /// </summary>
@ -25,5 +25,4 @@ namespace LightweightIocContainer.Interfaces
/// <param name="arguments">The constructor arguments</param> /// <param name="arguments">The constructor arguments</param>
/// <returns>An instance of the given <see cref="Type"/></returns> /// <returns>An instance of the given <see cref="Type"/></returns>
T Resolve<T>(params object[] arguments); T Resolve<T>(params object[] arguments);
}
} }

@ -5,16 +5,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
namespace LightweightIocContainer.Interfaces.Installers namespace LightweightIocContainer.Interfaces.Installers;
/// <summary>
/// An <see cref="IIocInstaller"/> that installs all <see cref="IIocInstaller"/>s for its given <see cref="Assembly"/>
/// </summary>
public interface IAssemblyInstaller : IIocInstaller
{ {
/// <summary>
/// An <see cref="IIocInstaller"/> that installs all <see cref="IIocInstaller"/>s for its given <see cref="Assembly"/>
/// </summary>
public interface IAssemblyInstaller : IIocInstaller
{
/// <summary> /// <summary>
/// The <see cref="IIocInstaller"/>s of the <see cref="Assembly"/> that this <see cref="IAssemblyInstaller"/> is installing /// The <see cref="IIocInstaller"/>s of the <see cref="Assembly"/> that this <see cref="IAssemblyInstaller"/> is installing
/// </summary> /// </summary>
List<IIocInstaller> Installers { get; } List<IIocInstaller> Installers { get; }
}
} }

@ -4,17 +4,16 @@
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Interfaces.Installers namespace LightweightIocContainer.Interfaces.Installers;
/// <summary>
/// The base class for <see cref="IIocContainer"/> installers
/// </summary>
public interface IIocInstaller
{ {
/// <summary>
/// The base class for <see cref="IIocContainer"/> installers
/// </summary>
public interface IIocInstaller
{
/// <summary> /// <summary>
/// Install the needed <see cref="IRegistration"/>s in the given <see cref="IIocContainer"/> /// Install the needed <see cref="IRegistration"/>s in the given <see cref="IIocContainer"/>
/// </summary> /// </summary>
/// <param name="registration">The <see cref="IRegistrationCollector"/> where <see cref="IRegistration"/>s are added</param> /// <param name="registration">The <see cref="IRegistrationCollector"/> where <see cref="IRegistration"/>s are added</param>
void Install(IRegistrationCollector registration); void Install(IRegistrationCollector registration);
}
} }

@ -5,32 +5,31 @@
using System; using System;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.Fluent namespace LightweightIocContainer.Interfaces.Registrations.Fluent;
/// <summary>
/// Provides an <see cref="OnCreateAction"/> to the generic <see cref="IOnCreate{TInterface, TImplementation}"/>
/// </summary>
public interface IOnCreate
{ {
/// <summary>
/// Provides an <see cref="OnCreateAction"/> to the generic <see cref="IOnCreate{TInterface, TImplementation}"/>
/// </summary>
public interface IOnCreate
{
/// <summary> /// <summary>
/// This <see cref="Action"/> is invoked when an instance of this type is created. /// This <see cref="Action"/> is invoked when an instance of this type is created.
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IOnCreate{TInterface, TImplementation}.OnCreate"/></para> /// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IOnCreate{TInterface, TImplementation}.OnCreate"/></para>
/// </summary> /// </summary>
internal Action<object?>? OnCreateAction { get; } internal Action<object?>? OnCreateAction { get; }
} }
/// <summary> /// <summary>
/// Provides an <see cref="OnCreate"/> method to an <see cref="IRegistrationBase"/> /// Provides an <see cref="OnCreate"/> method to an <see cref="IRegistrationBase"/>
/// </summary> /// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam> /// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam> /// <typeparam name="TImplementation">The registered implementation</typeparam>
public interface IOnCreate<TInterface, TImplementation> : IOnCreate where TImplementation : TInterface public interface IOnCreate<TInterface, TImplementation> : IOnCreate where TImplementation : TInterface
{ {
/// <summary> /// <summary>
/// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created /// Pass an <see cref="Action{T}"/> that will be invoked when an instance of this type is created
/// </summary> /// </summary>
/// <param name="action">The <see cref="Action{T}"/></param> /// <param name="action">The <see cref="Action{T}"/></param>
/// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns> /// <returns>The current instance of this <see cref="ITypedRegistration{TInterface,TImplementation}"/></returns>
ITypedRegistration<TInterface, TImplementation> OnCreate(Action<TImplementation?> action); ITypedRegistration<TInterface, TImplementation> OnCreate(Action<TImplementation?> action);
}
} }

@ -4,13 +4,13 @@
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Interfaces.Registrations.Fluent namespace LightweightIocContainer.Interfaces.Registrations.Fluent;
/// <summary>
/// Provides a <see cref="WithFactory{TFactory}"/> method to an <see cref="IRegistrationBase"/>
/// </summary>
public interface IWithFactory
{ {
/// <summary>
/// Provides a <see cref="WithFactory{TFactory}"/> method to an <see cref="IRegistrationBase"/>
/// </summary>
public interface IWithFactory
{
/// <summary> /// <summary>
/// Register an abstract typed factory for the <see cref="IRegistrationBase"/> /// Register an abstract typed factory for the <see cref="IRegistrationBase"/>
/// </summary> /// </summary>
@ -25,13 +25,12 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
/// <typeparam name="TFactoryImplementation">The type of the implementation 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> /// <returns>The current instance of this <see cref="IRegistrationBase"/></returns>
IRegistrationBase WithFactory<TFactoryInterface, TFactoryImplementation>() where TFactoryImplementation : TFactoryInterface; IRegistrationBase WithFactory<TFactoryInterface, TFactoryImplementation>() where TFactoryImplementation : TFactoryInterface;
} }
internal interface IWithFactoryInternal : IWithFactory internal interface IWithFactoryInternal : IWithFactory
{ {
/// <summary> /// <summary>
/// The Factory added with the <see cref="IWithFactory.WithFactory{TFactory}"/> method /// The Factory added with the <see cref="IWithFactory.WithFactory{TFactory}"/> method
/// </summary> /// </summary>
ITypedFactory? Factory { get; } ITypedFactory? Factory { get; }
}
} }

@ -6,13 +6,13 @@ using System;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
namespace LightweightIocContainer.Interfaces.Registrations.Fluent namespace LightweightIocContainer.Interfaces.Registrations.Fluent;
/// <summary>
/// Provides a <see cref="WithParameters(object[])"/> method to an <see cref="IRegistration"/>
/// </summary>
public interface IWithParameters
{ {
/// <summary>
/// Provides a <see cref="WithParameters(object[])"/> method to an <see cref="IRegistration"/>
/// </summary>
public interface IWithParameters
{
/// <summary> /// <summary>
/// Pass parameters that will be used to<see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// Pass parameters that will be used to<see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> /// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
@ -30,14 +30,13 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
/// <returns>The current instance of this <see cref="IRegistrationBase"/></returns> /// <returns>The current instance of this <see cref="IRegistrationBase"/></returns>
/// <exception cref="InvalidRegistrationException"><see cref="IWithParametersInternal.Parameters"/> are already set or no parameters given</exception> /// <exception cref="InvalidRegistrationException"><see cref="IWithParametersInternal.Parameters"/> are already set or no parameters given</exception>
IRegistrationBase WithParameters(params (int index, object parameter)[] parameters); IRegistrationBase WithParameters(params (int index, object parameter)[] parameters);
} }
internal interface IWithParametersInternal : IWithParameters internal interface IWithParametersInternal : IWithParameters
{ {
/// <summary> /// <summary>
/// An <see cref="Array"/> of parameters that are used to <see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// An <see cref="Array"/> of parameters that are used to <see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IWithParameters.WithParameters(object[])"/></para> /// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IWithParameters.WithParameters(object[])"/></para>
/// </summary> /// </summary>
object[]? Parameters { get; } object[]? Parameters { get; }
}
} }

@ -2,16 +2,15 @@
// // Created: 2020-01-29 // // Created: 2020-01-29
// // Copyright(c) 2020 SimonG. All Rights Reserved. // // Copyright(c) 2020 SimonG. All Rights Reserved.
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// Provides a <see cref="LightweightIocContainer.Lifestyle"/> to an <see cref="IRegistration"/>
/// </summary>
public interface ILifestyleProvider
{ {
/// <summary>
/// Provides a <see cref="LightweightIocContainer.Lifestyle"/> to an <see cref="IRegistration"/>
/// </summary>
public interface ILifestyleProvider
{
/// <summary> /// <summary>
/// The Lifestyle of Instances that are created with this <see cref="IRegistration"/> /// The Lifestyle of Instances that are created with this <see cref="IRegistration"/>
/// </summary> /// </summary>
Lifestyle Lifestyle { get; } Lifestyle Lifestyle { get; }
}
} }

@ -2,16 +2,15 @@
// Created: 2020-11-19 // Created: 2020-11-19
// Copyright(c) 2020 SimonG. All Rights Reserved. // Copyright(c) 2020 SimonG. All Rights Reserved.
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// 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>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> : IMultitonRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{ {
/// <summary>
/// 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>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> : IMultitonRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{
}
} }

@ -4,68 +4,67 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// The base interface for every <see cref="IMultipleRegistration{TInterface1,TInterface2,TImplementation}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TImplementation> : ITypedRegistration<TInterface1, TImplementation> where TImplementation : TInterface1
{ {
/// <summary>
/// The base interface for every <see cref="IMultipleRegistration{TInterface1,TInterface2,TImplementation}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TImplementation> : ITypedRegistration<TInterface1, TImplementation> where TImplementation : TInterface1
{
/// <summary> /// <summary>
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1,TImplementation}"/> /// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="IMultipleRegistration{TInterface1,TImplementation}"/>
/// </summary> /// </summary>
List<IRegistration> Registrations { get; } List<IRegistration> Registrations { get; }
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2 public interface IMultipleRegistration<TInterface1, TInterface2, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2
{ {
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam> /// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3 public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3
{ {
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam> /// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam> /// <typeparam name="TInterface4">The fourth interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4 public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4
{ {
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam> /// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam> /// <typeparam name="TInterface4">The fourth interface</typeparam>
/// <typeparam name="TInterface5">The fifth interface</typeparam> /// <typeparam name="TInterface5">The fifth interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5 public interface IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> : IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1, TInterface2, TInterface3, TInterface4, TInterface5
{ {
}
} }

@ -4,26 +4,25 @@
using System; using System;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// Non generic <see cref="IMultipleRegistration{TInterface1,TImplementation}"/>
/// </summary>
public interface IMultitonRegistration : ITypedRegistration
{ {
/// <summary>
/// Non generic <see cref="IMultipleRegistration{TInterface1,TImplementation}"/>
/// </summary>
public interface IMultitonRegistration : ITypedRegistration
{
/// <summary> /// <summary>
/// The <see cref="Type"/> of the multiton scope /// The <see cref="Type"/> of the multiton scope
/// </summary> /// </summary>
Type Scope { get; } Type Scope { get; }
} }
/// <summary> /// <summary>
/// The registration that is used to register a multiton /// The registration that is used to register a multiton
/// </summary> /// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam> /// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam> /// <typeparam name="TImplementation">The registered implementation</typeparam>
public interface IMultitonRegistration<TInterface, TImplementation> : IMultitonRegistration, ITypedRegistration<TInterface, TImplementation> where TImplementation : TInterface public interface IMultitonRegistration<TInterface, TImplementation> : IMultitonRegistration, ITypedRegistration<TInterface, TImplementation> where TImplementation : TInterface
{ {
}
} }

@ -2,13 +2,12 @@
// Created: 2020-09-18 // Created: 2020-09-18
// Copyright(c) 2020 SimonG. All Rights Reserved. // Copyright(c) 2020 SimonG. All Rights Reserved.
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// <see cref="IRegistration"/> for open generic types
/// </summary>
public interface IOpenGenericRegistration : ITypedRegistration
{ {
/// <summary>
/// <see cref="IRegistration"/> for open generic types
/// </summary>
public interface IOpenGenericRegistration : ITypedRegistration
{
}
} }

@ -4,16 +4,15 @@
using System; using System;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// The base registration that is used to register an Interface
/// </summary>
public interface IRegistration
{ {
/// <summary>
/// The base registration that is used to register an Interface
/// </summary>
public interface IRegistration
{
/// <summary> /// <summary>
/// The <see cref="Type"/> of the Interface that is registered with this <see cref="IRegistration"/> /// The <see cref="Type"/> of the Interface that is registered with this <see cref="IRegistration"/>
/// </summary> /// </summary>
Type InterfaceType { get; } Type InterfaceType { get; }
}
} }

@ -4,13 +4,12 @@
using LightweightIocContainer.Interfaces.Registrations.Fluent; using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// 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, IWithFactory, IWithParameters, IWithDisposeStrategy
{ {
/// <summary>
/// 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, IWithFactory, IWithParameters, IWithDisposeStrategy
{
}
} }

@ -4,14 +4,14 @@
using System; using System;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// 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="IRegistration"/></typeparam>
public interface ISingleTypeRegistration<T> : IRegistrationBase
{ {
/// <summary>
/// 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="IRegistration"/></typeparam>
public interface ISingleTypeRegistration<T> : IRegistrationBase
{
/// <summary> /// <summary>
/// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way /// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way
/// </summary> /// </summary>
@ -23,5 +23,4 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param> /// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param>
/// <returns>The current instance of this <see cref="IRegistration"/></returns> /// <returns>The current instance of this <see cref="IRegistration"/></returns>
ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocResolver, T> factoryMethod); ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocResolver, T> factoryMethod);
}
} }

@ -4,17 +4,16 @@
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// The registration that is used to register an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The type of the abstract typed factory</typeparam>
public interface ITypedFactoryRegistration<TFactory> : IRegistration
{ {
/// <summary>
/// The registration that is used to register an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The type of the abstract typed factory</typeparam>
public interface ITypedFactoryRegistration<TFactory> : IRegistration
{
/// <summary> /// <summary>
/// The class that contains the implemented abstract factory of this <see cref="ITypedFactoryRegistration{TFactory}"/> /// The class that contains the implemented abstract factory of this <see cref="ITypedFactoryRegistration{TFactory}"/>
/// </summary> /// </summary>
ITypedFactory<TFactory> Factory { get; } ITypedFactory<TFactory> Factory { get; }
}
} }

@ -5,24 +5,23 @@
using System; using System;
using LightweightIocContainer.Interfaces.Registrations.Fluent; using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Interfaces.Registrations namespace LightweightIocContainer.Interfaces.Registrations;
/// <summary>
/// A base <see cref="ITypedRegistration"/> without generic interface and implementation
/// </summary>
public interface ITypedRegistration : IRegistrationBase
{ {
/// <summary>
/// A base <see cref="ITypedRegistration"/> without generic interface and implementation
/// </summary>
public interface ITypedRegistration : IRegistrationBase
{
/// <summary> /// <summary>
/// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IRegistration"/> /// The <see cref="Type"/> that implements the <see cref="IRegistration.InterfaceType"/> that is registered with this <see cref="IRegistration"/>
/// </summary> /// </summary>
Type ImplementationType { get; } Type ImplementationType { get; }
} }
/// <summary> /// <summary>
/// A <see cref="IRegistration"/> that implements a <see cref="Type"/> /// A <see cref="IRegistration"/> that implements a <see cref="Type"/>
/// </summary> /// </summary>
public interface ITypedRegistration<TInterface, TImplementation> : ITypedRegistration, IOnCreate<TInterface, TImplementation> where TImplementation : TInterface public interface ITypedRegistration<TInterface, TImplementation> : ITypedRegistration, IOnCreate<TInterface, TImplementation> where TImplementation : TInterface
{ {
}
} }

@ -16,13 +16,13 @@ using LightweightIocContainer.Interfaces.Registrations.Fluent;
using LightweightIocContainer.Registrations; using LightweightIocContainer.Registrations;
using LightweightIocContainer.ResolvePlaceholders; using LightweightIocContainer.ResolvePlaceholders;
namespace LightweightIocContainer namespace LightweightIocContainer;
/// <summary>
/// The main container that carries all the <see cref="IRegistration"/>s and can resolve all the types you'll ever want
/// </summary>
public class IocContainer : IIocContainer, IIocResolver
{ {
/// <summary>
/// The main container that carries all the <see cref="IRegistration"/>s and can resolve all the types you'll ever want
/// </summary>
public class IocContainer : IIocContainer, IIocResolver
{
private readonly RegistrationFactory _registrationFactory; private readonly RegistrationFactory _registrationFactory;
private readonly List<(Type type, object? instance)> _singletons = new(); private readonly List<(Type type, object? instance)> _singletons = new();
@ -662,5 +662,4 @@ namespace LightweightIocContainer
_singletons.Clear(); _singletons.Clear();
_multitons.Clear(); _multitons.Clear();
} }
}
} }

@ -4,13 +4,13 @@
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer namespace LightweightIocContainer;
/// <summary>
/// The Lifestyles that can be used for a <see cref="IRegistrationBase"/>
/// </summary>
public enum Lifestyle
{ {
/// <summary>
/// The Lifestyles that can be used for a <see cref="IRegistrationBase"/>
/// </summary>
public enum Lifestyle
{
/// <summary> /// <summary>
/// A new instance gets created every time an instance is resolved /// A new instance gets created every time an instance is resolved
/// </summary> /// </summary>
@ -25,5 +25,4 @@ namespace LightweightIocContainer
/// A new instance gets created if the given scope has no created instance yet. Otherwise the already created instance is used. /// A new instance gets created if the given scope has no created instance yet. Otherwise the already created instance is used.
/// </summary> /// </summary>
Multiton Multiton
}
} }

@ -7,16 +7,16 @@ using System.Collections.Generic;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// 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>
/// <typeparam name="TImplementation">The implementation</typeparam>
internal class MultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> : MultitonRegistration<TInterface1, TImplementation>, IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{ {
/// <summary>
/// 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>
/// <typeparam name="TImplementation">The implementation</typeparam>
internal class MultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> : MultitonRegistration<TInterface1, TImplementation>, IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{
/// <summary> /// <summary>
/// An <see cref="IRegistrationBase"/> 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> /// </summary>
@ -57,5 +57,4 @@ namespace LightweightIocContainer.Registrations
return this; return this;
} }
}
} }

@ -7,15 +7,15 @@ using System.Collections.Generic;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2, TImplementation}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam>
internal 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, TImplementation}"/> to register multiple interfaces
/// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam>
internal abstract class MultipleRegistration<TInterface1, TImplementation> : TypedRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TImplementation> where TImplementation : TInterface1
{
/// <summary> /// <summary>
/// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces /// The base class for every <see cref="IMultipleRegistration{TInterface1,TInterface2}"/> to register multiple interfaces
/// </summary> /// </summary>
@ -31,16 +31,16 @@ namespace LightweightIocContainer.Registrations
/// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="MultipleRegistration{TInterface1,TInterface2}"/> /// A <see cref="List{T}"/> of <see cref="IRegistration"/>s that are registered within this <see cref="MultipleRegistration{TInterface1,TInterface2}"/>
/// </summary> /// </summary>
public List<IRegistration> Registrations { get; protected init; } public List<IRegistration> Registrations { get; protected init; }
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
internal class MultipleRegistration<TInterface1, TInterface2, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2 internal class MultipleRegistration<TInterface1, TInterface2, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TImplementation> where TImplementation : TInterface1, TInterface2
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
@ -76,17 +76,17 @@ namespace LightweightIocContainer.Registrations
return this; return this;
} }
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam> /// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
internal class MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> where TImplementation : TInterface3, TInterface2, TInterface1 internal class MultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TImplementation> where TImplementation : TInterface3, TInterface2, TInterface1
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
@ -126,18 +126,18 @@ namespace LightweightIocContainer.Registrations
return this; return this;
} }
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam> /// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam> /// <typeparam name="TInterface4">The fourth interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
internal class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1 internal class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TImplementation> where TImplementation : TInterface4, TInterface3, TInterface2, TInterface1
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
@ -181,19 +181,19 @@ namespace LightweightIocContainer.Registrations
return this; return this;
} }
} }
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
/// <typeparam name="TInterface1">The first interface</typeparam> /// <typeparam name="TInterface1">The first interface</typeparam>
/// <typeparam name="TInterface2">The second interface</typeparam> /// <typeparam name="TInterface2">The second interface</typeparam>
/// <typeparam name="TInterface3">The third interface</typeparam> /// <typeparam name="TInterface3">The third interface</typeparam>
/// <typeparam name="TInterface4">The fourth interface</typeparam> /// <typeparam name="TInterface4">The fourth interface</typeparam>
/// <typeparam name="TInterface5">The fifth interface</typeparam> /// <typeparam name="TInterface5">The fifth interface</typeparam>
/// <typeparam name="TImplementation">The implementation</typeparam> /// <typeparam name="TImplementation">The implementation</typeparam>
internal 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 internal class MultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> : MultipleRegistration<TInterface1, TImplementation>, IMultipleRegistration<TInterface1, TInterface2, TInterface3, TInterface4, TInterface5, TImplementation> where TImplementation : TInterface5, TInterface4, TInterface3, TInterface2, TInterface1
{ {
/// <summary> /// <summary>
/// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type /// An <see cref="IRegistration"/> to register multiple interfaces for on implementation type
/// </summary> /// </summary>
@ -241,5 +241,4 @@ namespace LightweightIocContainer.Registrations
return this; return this;
} }
}
} }

@ -8,15 +8,15 @@ using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// The registration that is used to register a multiton
/// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam>
internal class MultitonRegistration<TInterface, TImplementation> : TypedRegistration<TInterface, TImplementation>, IMultitonRegistration<TInterface, TImplementation> where TImplementation : TInterface
{ {
/// <summary>
/// The registration that is used to register a multiton
/// </summary>
/// <typeparam name="TInterface">The registered interface</typeparam>
/// <typeparam name="TImplementation">The registered implementation</typeparam>
internal class MultitonRegistration<TInterface, TImplementation> : TypedRegistration<TInterface, TImplementation>, IMultitonRegistration<TInterface, TImplementation> where TImplementation : TInterface
{
/// <summary> /// <summary>
/// The registration that is used to register a multiton /// The registration that is used to register a multiton
/// </summary> /// </summary>
@ -55,5 +55,4 @@ namespace LightweightIocContainer.Registrations
Scope == multitonRegistration.Scope; Scope == multitonRegistration.Scope;
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Scope); public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Scope);
}
} }

@ -7,13 +7,13 @@ using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// <see cref="IRegistration"/> for open generic types
/// </summary>
internal class OpenGenericRegistration : RegistrationBase, IOpenGenericRegistration
{ {
/// <summary>
/// <see cref="IRegistration"/> for open generic types
/// </summary>
internal class OpenGenericRegistration : RegistrationBase, IOpenGenericRegistration
{
/// <summary> /// <summary>
/// <see cref="IRegistration"/> for open generic types /// <see cref="IRegistration"/> for open generic types
/// </summary> /// </summary>
@ -49,5 +49,4 @@ namespace LightweightIocContainer.Registrations
ImplementationType == openGenericRegistration.ImplementationType; ImplementationType == openGenericRegistration.ImplementationType;
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), ImplementationType); public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), ImplementationType);
}
} }

@ -12,13 +12,13 @@ using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Interfaces.Registrations.Fluent; using LightweightIocContainer.Interfaces.Registrations.Fluent;
using LightweightIocContainer.ResolvePlaceholders; using LightweightIocContainer.ResolvePlaceholders;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// The <see cref="RegistrationBase"/> that is used to register an Interface
/// </summary>
internal abstract class RegistrationBase : IRegistrationBase, IWithFactoryInternal, IWithParametersInternal, ILifestyleProvider, IWithDisposeStrategyInternal, IInternalValidationProvider
{ {
/// <summary>
/// The <see cref="RegistrationBase"/> that is used to register an Interface
/// </summary>
internal abstract class RegistrationBase : IRegistrationBase, IWithFactoryInternal, IWithParametersInternal, ILifestyleProvider, IWithDisposeStrategyInternal, IInternalValidationProvider
{
private readonly IocContainer _container; private readonly IocContainer _container;
/// <summary> /// <summary>
@ -243,5 +243,4 @@ namespace LightweightIocContainer.Registrations
} }
public override int GetHashCode() => HashCode.Combine(InterfaceType, (int) Lifestyle); public override int GetHashCode() => HashCode.Combine(InterfaceType, (int) Lifestyle);
}
} }

@ -7,13 +7,13 @@ using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// A factory to register interfaces and factories in an <see cref="IIocInstaller"/> and create the needed <see cref="IRegistration"/>s
/// </summary>
internal class RegistrationFactory
{ {
/// <summary>
/// A factory to register interfaces and factories in an <see cref="IIocInstaller"/> and create the needed <see cref="IRegistration"/>s
/// </summary>
internal class RegistrationFactory
{
private readonly IocContainer _iocContainer; private readonly IocContainer _iocContainer;
internal RegistrationFactory(IocContainer container) => _iocContainer = container; internal RegistrationFactory(IocContainer container) => _iocContainer = container;
@ -123,5 +123,4 @@ namespace LightweightIocContainer.Registrations
/// <typeparam name="TFactory">The abstract typed factory to register</typeparam> /// <typeparam name="TFactory">The abstract typed factory to register</typeparam>
/// <returns>A new created <see cref="ITypedFactoryRegistration{TFactory}"/> with the given parameters</returns> /// <returns>A new created <see cref="ITypedFactoryRegistration{TFactory}"/> with the given parameters</returns>
public ITypedFactoryRegistration<TFactory> RegisterFactory<TFactory>(ITypedFactory<TFactory> factory) => new TypedFactoryRegistration<TFactory>(factory); public ITypedFactoryRegistration<TFactory> RegisterFactory<TFactory>(ITypedFactory<TFactory> factory) => new TypedFactoryRegistration<TFactory>(factory);
}
} }

@ -6,14 +6,14 @@ using System;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// 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="IRegistration"/></typeparam>
internal class SingleTypeRegistration<T> : RegistrationBase, ISingleTypeRegistration<T>
{ {
/// <summary>
/// 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="IRegistration"/></typeparam>
internal class SingleTypeRegistration<T> : RegistrationBase, ISingleTypeRegistration<T>
{
/// <summary> /// <summary>
/// The <see cref="IRegistration"/> to register either only an interface or only a <see cref="Type"/> /// The <see cref="IRegistration"/> to register either only an interface or only a <see cref="Type"/>
/// </summary> /// </summary>
@ -57,5 +57,4 @@ namespace LightweightIocContainer.Registrations
} }
public override int GetHashCode() => base.GetHashCode(); public override int GetHashCode() => base.GetHashCode();
}
} }

@ -6,14 +6,14 @@ using System;
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// The registration that is used to register an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The <see cref="Type"/> of the abstract typed factory</typeparam>
internal class TypedFactoryRegistration<TFactory> : ITypedFactoryRegistration<TFactory>
{ {
/// <summary>
/// The registration that is used to register an abstract typed factory
/// </summary>
/// <typeparam name="TFactory">The <see cref="Type"/> of the abstract typed factory</typeparam>
internal class TypedFactoryRegistration<TFactory> : ITypedFactoryRegistration<TFactory>
{
/// <summary> /// <summary>
/// The registration that is used to register an abstract typed factory /// The registration that is used to register an abstract typed factory
/// </summary> /// </summary>
@ -35,5 +35,4 @@ namespace LightweightIocContainer.Registrations
InterfaceType == factoryRegistration.InterfaceType; InterfaceType == factoryRegistration.InterfaceType;
public override int GetHashCode() => HashCode.Combine(InterfaceType); public override int GetHashCode() => HashCode.Combine(InterfaceType);
}
} }

@ -8,13 +8,13 @@ using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Interfaces.Registrations.Fluent; using LightweightIocContainer.Interfaces.Registrations.Fluent;
namespace LightweightIocContainer.Registrations namespace LightweightIocContainer.Registrations;
/// <summary>
/// A <see cref="IRegistrationBase"/> that implements a <see cref="Type"/>
/// </summary>
internal class TypedRegistration<TInterface, TImplementation> : RegistrationBase, ITypedRegistration<TInterface, TImplementation> where TImplementation : TInterface
{ {
/// <summary>
/// A <see cref="IRegistrationBase"/> that implements a <see cref="Type"/>
/// </summary>
internal class TypedRegistration<TInterface, TImplementation> : RegistrationBase, ITypedRegistration<TInterface, TImplementation> where TImplementation : TInterface
{
/// <summary> /// <summary>
/// A <see cref="IRegistrationBase"/> that implements a <see cref="Type"/> /// A <see cref="IRegistrationBase"/> that implements a <see cref="Type"/>
/// </summary> /// </summary>
@ -77,5 +77,4 @@ namespace LightweightIocContainer.Registrations
} }
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), ImplementationType); public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), ImplementationType);
}
} }

@ -2,13 +2,12 @@
// Created: 2019-11-22 // Created: 2019-11-22
// Copyright(c) 2019 SimonG. All Rights Reserved. // Copyright(c) 2019 SimonG. All Rights Reserved.
namespace LightweightIocContainer.ResolvePlaceholders namespace LightweightIocContainer.ResolvePlaceholders;
/// <summary>
/// An internal placeholder that is used during the resolving process
/// </summary>
internal class InternalResolvePlaceholder
{ {
/// <summary>
/// An internal placeholder that is used during the resolving process
/// </summary>
internal class InternalResolvePlaceholder
{
}
} }

@ -6,13 +6,13 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.ResolvePlaceholders namespace LightweightIocContainer.ResolvePlaceholders;
/// <summary>
/// An internal placeholder that is used to hold types that need to be resolved during the resolving process
/// </summary>
internal class InternalToBeResolvedPlaceholder : IInternalToBeResolvedPlaceholder
{ {
/// <summary>
/// An internal placeholder that is used to hold types that need to be resolved during the resolving process
/// </summary>
internal class InternalToBeResolvedPlaceholder : IInternalToBeResolvedPlaceholder
{
public InternalToBeResolvedPlaceholder(Type resolvedType, IRegistration resolvedRegistration, List<object?>? parameters) public InternalToBeResolvedPlaceholder(Type resolvedType, IRegistration resolvedRegistration, List<object?>? parameters)
{ {
ResolvedType = resolvedType; ResolvedType = resolvedType;
@ -34,5 +34,4 @@ namespace LightweightIocContainer.ResolvePlaceholders
/// The parameters needed to resolve the <see cref="ResolvedRegistration"/> /// The parameters needed to resolve the <see cref="ResolvedRegistration"/>
/// </summary> /// </summary>
public List<object?>? Parameters { get; } public List<object?>? Parameters { get; }
}
} }

@ -4,15 +4,14 @@
using System; using System;
namespace LightweightIocContainer namespace LightweightIocContainer;
internal static class TypeExtension
{ {
internal static class TypeExtension
{
/// <summary> /// <summary>
/// Returns the default value for a given <see cref="Type"/> /// Returns the default value for a given <see cref="Type"/>
/// </summary> /// </summary>
/// <param name="type">The given <see cref="Type"/></param> /// <param name="type">The given <see cref="Type"/></param>
/// <returns>The default value for the given <see cref="Type"/></returns> /// <returns>The default value for the given <see cref="Type"/></returns>
public static object? GetDefault(this Type type) => type.IsValueType ? Activator.CreateInstance(type) : null; public static object? GetDefault(this Type type) => type.IsValueType ? Activator.CreateInstance(type) : null;
}
} }

@ -9,13 +9,13 @@ using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Interfaces.Registrations.Fluent; using LightweightIocContainer.Interfaces.Registrations.Fluent;
using Moq; using Moq;
namespace LightweightIocContainer.Validation namespace LightweightIocContainer.Validation;
/// <summary>
/// Validator for your <see cref="IocContainer"/> to check if everything can be resolved with your current setup
/// </summary>
public class IocValidator
{ {
/// <summary>
/// Validator for your <see cref="IocContainer"/> to check if everything can be resolved with your current setup
/// </summary>
public class IocValidator
{
private readonly IocContainer _iocContainer; private readonly IocContainer _iocContainer;
private readonly List<(Type type, object? parameter)> _parameters; private readonly List<(Type type, object? parameter)> _parameters;
@ -102,5 +102,4 @@ namespace LightweightIocContainer.Validation
return null; return null;
} }
} }
}
} }

@ -6,11 +6,11 @@ using System;
using LightweightIocContainer; using LightweightIocContainer;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class ActionExtensionTest
{ {
[TestFixture]
public class ActionExtensionTest
{
private interface IBar private interface IBar
{ {
void Throw(); void Throw();
@ -42,5 +42,4 @@ namespace Test.LightweightIocContainer
Action<IBar> barAction = null; Action<IBar> barAction = null;
Assert.Null(barAction.Convert<IFoo, IBar>()); Assert.Null(barAction.Convert<IFoo, IBar>());
} }
}
} }

@ -14,11 +14,11 @@ using LightweightIocContainer.Interfaces.Registrations;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class AssemblyInstallerTest
{ {
[TestFixture]
public class AssemblyInstallerTest
{
[UsedImplicitly] [UsedImplicitly]
public class TestInstaller : IIocInstaller public class TestInstaller : IIocInstaller
{ {
@ -74,5 +74,4 @@ namespace Test.LightweightIocContainer
IIocContainer iocContainer = new IocContainer(); IIocContainer iocContainer = new IocContainer();
iocContainer.Install(FromAssembly.Instance(assemblyMock.Object)); iocContainer.Install(FromAssembly.Instance(assemblyMock.Object));
} }
}
} }

@ -9,11 +9,11 @@ using LightweightIocContainer;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class EnumerableExtensionTest
{ {
[TestFixture]
public class EnumerableExtensionTest
{
private class ListObject private class ListObject
{ {
public int Index { get; set; } public int Index { get; set; }
@ -98,5 +98,4 @@ namespace Test.LightweightIocContainer
test3.Verify(t => t.DoSomething(), Times.Once); test3.Verify(t => t.DoSomething(), Times.Once);
test4.Verify(t => t.DoSomething(), Times.Once); test4.Verify(t => t.DoSomething(), Times.Once);
} }
}
} }

@ -7,11 +7,11 @@ using LightweightIocContainer;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class FluentFactoryRegistrationTest
{ {
[TestFixture]
public class FluentFactoryRegistrationTest
{
public interface ITest public interface ITest
{ {
@ -269,5 +269,4 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestInvalidCreateMethodReturnType() => public void TestInvalidCreateMethodReturnType() =>
Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.Register(r => r.Add<ITest, Test>().WithFactory<ITestFactoryWrongReturn>())); Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.Register(r => r.Add<ITest, Test>().WithFactory<ITestFactoryWrongReturn>()));
}
} }

@ -7,11 +7,11 @@ using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class IocContainerInterfaceSegregationTest
{ {
[TestFixture]
public class IocContainerInterfaceSegregationTest
{
private interface IBar private interface IBar
{ {
@ -160,5 +160,4 @@ namespace Test.LightweightIocContainer
Assert.AreSame(foo, anotherBar); Assert.AreSame(foo, anotherBar);
Assert.AreSame(foo, anotherOne); Assert.AreSame(foo, anotherOne);
} }
}
} }

@ -6,12 +6,12 @@ using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
// ReSharper disable MemberHidesStaticFromOuterClass
public class IocContainerParameterRegistrationTest
{ {
[TestFixture]
// ReSharper disable MemberHidesStaticFromOuterClass
public class IocContainerParameterRegistrationTest
{
[UsedImplicitly] [UsedImplicitly]
public interface IA public interface IA
{ {
@ -155,5 +155,4 @@ namespace Test.LightweightIocContainer
Assert.AreEqual(a, d.A2); Assert.AreEqual(a, d.A2);
Assert.AreEqual(a2, d.A); Assert.AreEqual(a2, d.A);
} }
}
} }

@ -9,11 +9,11 @@ using LightweightIocContainer.Exceptions;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class IocContainerRecursionTest
{ {
[TestFixture]
public class IocContainerRecursionTest
{
[UsedImplicitly] [UsedImplicitly]
public interface IFoo public interface IFoo
{ {
@ -162,5 +162,4 @@ namespace Test.LightweightIocContainer
Assert.DoesNotThrow(() => _iocContainer.Resolve<IA>()); Assert.DoesNotThrow(() => _iocContainer.Resolve<IA>());
Assert.DoesNotThrow(() => _iocContainer.Resolve<IB>()); Assert.DoesNotThrow(() => _iocContainer.Resolve<IB>());
} }
}
} }

@ -7,11 +7,11 @@ using LightweightIocContainer.Interfaces.Registrations;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class IocContainerTest
{ {
[TestFixture]
public class IocContainerTest
{
private interface ITest private interface ITest
{ {
@ -358,5 +358,4 @@ namespace Test.LightweightIocContainer
_iocContainer.Register(r => r.Add<Test>()); _iocContainer.Register(r => r.Add<Test>());
Assert.True(_iocContainer.IsTypeRegistered<Test>()); Assert.True(_iocContainer.IsTypeRegistered<Test>());
} }
}
} }

@ -12,11 +12,11 @@ using LightweightIocContainer.Validation;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class IocValidatorTest
{ {
[TestFixture]
public class IocValidatorTest
{
public interface ITest public interface ITest
{ {
@ -184,5 +184,4 @@ namespace Test.LightweightIocContainer
else else
Assert.Fail($"Exception is no NoMatchingConstructorFoundException, actual type: {exception?.GetType()}"); Assert.Fail($"Exception is no NoMatchingConstructorFoundException, actual type: {exception?.GetType()}");
} }
}
} }

@ -6,11 +6,11 @@ using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class MultipleMultitonRegistrationTest
{ {
[TestFixture]
public class MultipleMultitonRegistrationTest
{
private IocContainer _iocContainer; private IocContainer _iocContainer;
[UsedImplicitly] [UsedImplicitly]
@ -97,5 +97,4 @@ namespace Test.LightweightIocContainer
Assert.AreEqual(test, provider); Assert.AreEqual(test, provider);
Assert.AreSame(test, provider); Assert.AreSame(test, provider);
} }
}
} }

@ -9,11 +9,11 @@ using LightweightIocContainer.Registrations;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class OnCreateTest
{ {
[TestFixture]
public class OnCreateTest
{
private interface ITest private interface ITest
{ {
void DoSomething(); void DoSomething();
@ -35,5 +35,4 @@ namespace Test.LightweightIocContainer
Assert.Throws<Exception>(() => testRegistration.OnCreateAction!(test)); Assert.Throws<Exception>(() => testRegistration.OnCreateAction!(test));
} }
}
} }

@ -8,11 +8,11 @@ using LightweightIocContainer;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class OpenGenericRegistrationTest
{ {
[TestFixture]
public class OpenGenericRegistrationTest
{
private IocContainer _iocContainer; private IocContainer _iocContainer;
[UsedImplicitly] [UsedImplicitly]
@ -65,5 +65,4 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestRegisterNonOpenGenericTypeWithOpenGenericsFunctionThrowsException() => public void TestRegisterNonOpenGenericTypeWithOpenGenericsFunctionThrowsException() =>
Assert.Throws<InvalidRegistrationException>(() => _iocContainer.Register(r => r.AddOpenGenerics(typeof(int), typeof(int)))); Assert.Throws<InvalidRegistrationException>(() => _iocContainer.Register(r => r.AddOpenGenerics(typeof(int), typeof(int))));
}
} }

@ -10,11 +10,11 @@ using LightweightIocContainer.ResolvePlaceholders;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
public class RegistrationBaseTest
{ {
[TestFixture]
public class RegistrationBaseTest
{
private interface ITest private interface ITest
{ {
@ -95,5 +95,4 @@ namespace Test.LightweightIocContainer
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((object[])null)); Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters((object[])null));
Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(((int index, object parameter)[])null)); Assert.Throws<InvalidRegistrationException>(() => registrationFactory.Register<IFoo, Foo>(Lifestyle.Transient).WithParameters(((int index, object parameter)[])null));
} }
}
} }

@ -9,12 +9,12 @@ using LightweightIocContainer.Registrations;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer;
[TestFixture]
// ReSharper disable MemberHidesStaticFromOuterClass
public class SingleTypeRegistrationTest
{ {
[TestFixture]
// ReSharper disable MemberHidesStaticFromOuterClass
public class SingleTypeRegistrationTest
{
private interface IFoo private interface IFoo
{ {
IBar Bar { get; } IBar Bar { get; }
@ -67,5 +67,4 @@ namespace Test.LightweightIocContainer
Assert.IsInstanceOf<Foo>(foo); Assert.IsInstanceOf<Foo>(foo);
Assert.AreEqual(bar, foo.Bar); Assert.AreEqual(bar, foo.Bar);
} }
}
} }
Loading…
Cancel
Save