diff --git a/LightweightIocContainer/ActionExtension.cs b/LightweightIocContainer/ActionExtension.cs
index cfc9d88..10dd279 100644
--- a/LightweightIocContainer/ActionExtension.cs
+++ b/LightweightIocContainer/ActionExtension.cs
@@ -15,7 +15,7 @@ namespace LightweightIocContainer
/// The of the given , has to implement
/// The given to convert
/// An converted from the given
- public static Action Convert(this Action action) where T1 : T2
+ public static Action? Convert(this Action? action) where T1 : T2
{
if (action == null)
return null;
diff --git a/LightweightIocContainer/EnumerableExtension.cs b/LightweightIocContainer/EnumerableExtension.cs
index b2bd14f..e7b5204 100644
--- a/LightweightIocContainer/EnumerableExtension.cs
+++ b/LightweightIocContainer/EnumerableExtension.cs
@@ -39,7 +39,7 @@ namespace LightweightIocContainer
/// The given
/// A function to test each element for a condition
/// The first element of the or a new instance of the given when no element is found
- private static TSource TryGetFirst(this IEnumerable source, Func predicate) where TGiven : TSource, new()
+ private static TSource TryGetFirst(this IEnumerable source, Func? predicate) where TGiven : TSource, new()
{
try
{
diff --git a/LightweightIocContainer/Exceptions/IocContainerException.cs b/LightweightIocContainer/Exceptions/IocContainerException.cs
index dada45e..2896a76 100644
--- a/LightweightIocContainer/Exceptions/IocContainerException.cs
+++ b/LightweightIocContainer/Exceptions/IocContainerException.cs
@@ -16,20 +16,15 @@ namespace LightweightIocContainer.Exceptions
///
/// A base for the
///
- protected IocContainerException()
- {
-
- }
+ protected IocContainerException() => InnerExceptions = new List();
///
/// A base for the
///
/// The message of the
protected IocContainerException(string message)
- : base(message)
- {
-
- }
+ : base(message) =>
+ InnerExceptions = new List();
///
/// A base for the
diff --git a/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs b/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs
index 1c9e080..b49ff68 100644
--- a/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs
+++ b/LightweightIocContainer/Exceptions/NoMatchingConstructorFoundException.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
-using System.Linq;
namespace LightweightIocContainer.Exceptions
{
@@ -17,12 +16,11 @@ namespace LightweightIocContainer.Exceptions
/// No matching constructor was found for the given or resolvable arguments
///
/// The with no matching constructor
- /// The inner exceptions of type
- public NoMatchingConstructorFoundException(Type type, params ConstructorNotMatchingException[] exceptions)
+ public NoMatchingConstructorFoundException(Type type)
: base($"No matching constructor for {type} found.")
{
Type = type;
- InnerExceptions = exceptions == null ? new List() : exceptions.OfType().ToList();
+ InnerExceptions = new List();
}
diff --git a/LightweightIocContainer/Factories/TypedFactory.cs b/LightweightIocContainer/Factories/TypedFactory.cs
index 022988c..88df1dd 100644
--- a/LightweightIocContainer/Factories/TypedFactory.cs
+++ b/LightweightIocContainer/Factories/TypedFactory.cs
@@ -24,7 +24,7 @@ namespace LightweightIocContainer.Factories
/// The
///
/// The current instance of the
- public TypedFactory(IIocContainer container) => CreateFactory(container);
+ public TypedFactory(IIocContainer container) => Factory = CreateFactory(container);
///
/// The implemented abstract typed factory/>
@@ -36,7 +36,7 @@ namespace LightweightIocContainer.Factories
///
/// Factory registration is invalid
/// Creation of abstract methods are illegal in their current state
- private void CreateFactory(IIocContainer container)
+ private TFactory CreateFactory(IIocContainer container)
{
Type factoryType = typeof(TFactory);
@@ -92,7 +92,7 @@ namespace LightweightIocContainer.Factories
}
else
{
- MethodInfo emptyArray = typeof(Array).GetMethod(nameof(Array.Empty))?.MakeGenericMethod(typeof(object));
+ MethodInfo? emptyArray = typeof(Array).GetMethod(nameof(Array.Empty))?.MakeGenericMethod(typeof(object));
generator.EmitCall(OpCodes.Call, emptyArray, null);
}
@@ -102,7 +102,7 @@ namespace LightweightIocContainer.Factories
}
//if factory contains a method to clear multiton instances
- MethodInfo multitonClearMethod = factoryType.GetMethods().FirstOrDefault(m => m.Name.Equals(CLEAR_MULTITON_INSTANCE_METHOD_NAME));
+ MethodInfo? multitonClearMethod = factoryType.GetMethods().FirstOrDefault(m => m.Name.Equals(CLEAR_MULTITON_INSTANCE_METHOD_NAME));
if (multitonClearMethod != null)
{
//create a method that looks like this
@@ -113,7 +113,7 @@ namespace LightweightIocContainer.Factories
if (multitonClearMethod.IsGenericMethod)
{
- Type typeToClear = multitonClearMethod.GetGenericArguments().FirstOrDefault();
+ Type? typeToClear = multitonClearMethod.GetGenericArguments().FirstOrDefault();
if (typeToClear == null)
throw new IllegalAbstractMethodCreationException("No Type to clear specified.", multitonClearMethod);
@@ -136,7 +136,7 @@ namespace LightweightIocContainer.Factories
}
}
- Factory = (TFactory) Activator.CreateInstance(typeBuilder.CreateTypeInfo().AsType(), container);
+ return (TFactory) Activator.CreateInstance(typeBuilder.CreateTypeInfo()?.AsType(), container);
}
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/GenericMethodCaller.cs b/LightweightIocContainer/GenericMethodCaller.cs
index 9663e34..8052c37 100644
--- a/LightweightIocContainer/GenericMethodCaller.cs
+++ b/LightweightIocContainer/GenericMethodCaller.cs
@@ -24,10 +24,10 @@ namespace LightweightIocContainer
/// The result of invoking the method
/// Could not find the generic method
/// Any thrown after invoking the generic method
- public static object Call(object caller, string functionName, Type genericParameter, BindingFlags bindingFlags, params object[] parameters)
+ public static object Call(object caller, string functionName, Type genericParameter, BindingFlags bindingFlags, params object?[] parameters)
{
- MethodInfo method = caller.GetType().GetMethod(functionName, bindingFlags);
- MethodInfo genericMethod = method?.MakeGenericMethod(genericParameter);
+ MethodInfo? method = caller.GetType().GetMethod(functionName, bindingFlags);
+ MethodInfo? genericMethod = method?.MakeGenericMethod(genericParameter);
if (genericMethod == null)
throw new GenericMethodNotFoundException(functionName);
@@ -52,7 +52,7 @@ namespace LightweightIocContainer
/// The result of invoking the method
/// Could not find the generic method
/// Any thrown after invoking the generic method
- 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);
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/Interfaces/Registrations/Fluent/IOnCreate.cs b/LightweightIocContainer/Interfaces/Registrations/Fluent/IOnCreate.cs
index 107e766..53507e3 100644
--- a/LightweightIocContainer/Interfaces/Registrations/Fluent/IOnCreate.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/Fluent/IOnCreate.cs
@@ -16,7 +16,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
/// This is invoked when an instance of this type is created.
/// Can be set in the by calling
///
- internal Action OnCreateAction { get; }
+ internal Action? OnCreateAction { get; }
}
///
@@ -31,6 +31,6 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
///
/// The
/// The current instance of this
- ITypedRegistration OnCreate(Action action);
+ ITypedRegistration OnCreate(Action action);
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs
index 01150a3..4db540f 100644
--- a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs
@@ -32,6 +32,6 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
///
/// The Factory added with the method
///
- ITypedFactory Factory { get; }
+ ITypedFactory? Factory { get; }
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs
index 7e56a87..1822d5b 100644
--- a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs
@@ -38,6 +38,6 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
/// An of parameters that are used to an instance of this
/// Can be set in the by calling
///
- object[] Parameters { get; }
+ object[]? Parameters { get; }
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs b/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs
index 0fece0d..eaa5746 100644
--- a/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs
+++ b/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs
@@ -15,7 +15,7 @@ namespace LightweightIocContainer.Interfaces.Registrations
///
/// that is invoked instead of creating an instance of this the default way
///
- Func FactoryMethod { get; }
+ Func? FactoryMethod { get; }
///
/// Pass a that will be invoked instead of creating an instance of this the default way
diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs
index 79127fc..34864f0 100644
--- a/LightweightIocContainer/IocContainer.cs
+++ b/LightweightIocContainer/IocContainer.cs
@@ -7,7 +7,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
-using JetBrains.Annotations;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories;
@@ -26,8 +25,8 @@ namespace LightweightIocContainer
{
private readonly RegistrationFactory _registrationFactory;
- private readonly List<(Type type, object instance)> _singletons = new();
- private readonly List<(Type type, Type scope, ConditionalWeakTable instances)> _multitons = new();
+ private readonly List<(Type type, object? instance)> _singletons = new();
+ private readonly List<(Type type, Type scope, ConditionalWeakTable instances)> _multitons = new();
///
/// The main container that carries all the s and can resolve all the types you'll ever want
@@ -266,7 +265,7 @@ namespace LightweightIocContainer
/// The current resolve stack
/// An instance of the given
/// Could not find function
- internal object Resolve(Type type, object[] arguments, List resolveStack) =>
+ internal object Resolve(Type type, object?[]? arguments, List? resolveStack) =>
GenericMethodCaller.CallPrivate(this, nameof(ResolveInternal), type, arguments, resolveStack);
///
@@ -301,7 +300,7 @@ namespace LightweightIocContainer
/// An instance of the given registered
/// The given is not registered in this
/// The registration for the given has an unknown
- private T ResolveInternal(object[] arguments, List resolveStack = null)
+ private T ResolveInternal(object[]? arguments, List? resolveStack = null)
{
IRegistration registration = FindRegistration() ?? throw new TypeNotRegisteredException(typeof(T));
@@ -330,11 +329,11 @@ namespace LightweightIocContainer
/// The arguments to resolve
/// The current resolve stack
/// An existing or newly created singleton instance of the given
- private T GetOrCreateSingletonInstance(IRegistration registration, object[] arguments, List resolveStack)
+ private T GetOrCreateSingletonInstance(IRegistration registration, object[]? arguments, List resolveStack)
{
Type type = GetType(registration);
- object instance = TryGetSingletonInstance(type);
+ object? instance = TryGetSingletonInstance(type);
if (instance != null)
return (T) instance;
@@ -350,7 +349,7 @@ namespace LightweightIocContainer
///
/// The given
/// A singleton instance if existing for the given , null if not
- private object TryGetSingletonInstance(Type type) => _singletons.FirstOrDefault(s => s.type == type).instance; //if a singleton instance exists return it
+ private object? TryGetSingletonInstance(Type type) => _singletons.FirstOrDefault(s => s.type == type).instance; //if a singleton instance exists return it
///
/// Gets or creates a multiton instance of a given
@@ -362,7 +361,7 @@ namespace LightweightIocContainer
/// An existing or newly created multiton instance of the given
/// No arguments given
/// Scope argument not given
- private T GetOrCreateMultitonInstance(IMultitonRegistration registration, object[] arguments, List resolveStack)
+ private T GetOrCreateMultitonInstance(IMultitonRegistration registration, object[]? arguments, List resolveStack)
{
if (arguments == null || !arguments.Any())
throw new MultitonResolveException("Can not resolve multiton without arguments.", typeof(T));
@@ -375,7 +374,7 @@ namespace LightweightIocContainer
var instances = _multitons.FirstOrDefault(m => m.type == registration.ImplementationType && m.scope == registration.Scope).instances; //get instances for the given type and scope (use implementation type to resolve the correct instance for multiple multiton registrations as well)
if (instances != null)
{
- if (instances.TryGetValue(scopeArgument, out object instance))
+ if (instances.TryGetValue(scopeArgument, out object? instance) && instance != null)
return (T) instance;
T createdInstance = CreateInstance(registration, arguments, resolveStack);
@@ -386,7 +385,7 @@ namespace LightweightIocContainer
T newInstance = CreateInstance(registration, arguments, resolveStack);
- ConditionalWeakTable weakTable = new();
+ ConditionalWeakTable weakTable = new();
weakTable.Add(scopeArgument, newInstance);
_multitons.Add((registration.ImplementationType, registration.Scope, weakTable));
@@ -402,7 +401,7 @@ namespace LightweightIocContainer
/// The constructor arguments
/// The current resolve stack
/// A newly created instance of the given
- private T CreateInstance(IRegistration registration, object[] arguments, List resolveStack)
+ private T CreateInstance(IRegistration registration, object[]? arguments, List resolveStack)
{
if (registration is IWithParametersInternal { Parameters: { } } registrationWithParameters)
arguments = UpdateArgumentsWithRegistrationParameters(registrationWithParameters, arguments);
@@ -430,7 +429,7 @@ namespace LightweightIocContainer
if (singleTypeRegistration.FactoryMethod == null) //type registration without interface -> just create this type
{
arguments = ResolveTypeCreationArguments(singleTypeRegistration.InterfaceType, arguments, resolveStack);
- instance = (T)Activator.CreateInstance(singleTypeRegistration.InterfaceType, arguments);
+ instance = (T) Activator.CreateInstance(singleTypeRegistration.InterfaceType, arguments);
}
else //factory method set to create the instance
instance = singleTypeRegistration.FactoryMethod(this);
@@ -450,8 +449,11 @@ namespace LightweightIocContainer
/// The of the given
/// The constructor arguments
/// The argument list updated with the
- private object[] UpdateArgumentsWithRegistrationParameters(IWithParametersInternal registration, object[] arguments)
+ private object[]? UpdateArgumentsWithRegistrationParameters(IWithParametersInternal registration, object[]? arguments)
{
+ if (registration.Parameters == null)
+ return arguments;
+
if (arguments != null && arguments.Any()) //if more arguments were passed to resolve
{
int argumentsSize = registration.Parameters.Length + arguments.Length;
@@ -495,10 +497,9 @@ namespace LightweightIocContainer
/// The current resolve stack
/// An array of all needed constructor arguments to create the
/// No matching constructor was found for the given or resolvable arguments
- [CanBeNull]
- private object[] ResolveTypeCreationArguments(Type type, object[] arguments, List resolveStack)
+ private object[]? ResolveTypeCreationArguments(Type type, object[]? arguments, List resolveStack)
{
- (bool result, List parameters, NoMatchingConstructorFoundException exception) = TryGetTypeResolveStack(type, arguments, resolveStack);
+ (bool result, List? parameters, NoMatchingConstructorFoundException? exception) = TryGetTypeResolveStack(type, arguments, resolveStack);
if (result)
{
@@ -534,15 +535,15 @@ namespace LightweightIocContainer
/// parameters: The parameters needed to resolve the given
/// exception: A if no matching constructor was found
///
- private (bool result, List parameters, NoMatchingConstructorFoundException exception) TryGetTypeResolveStack(Type type, object[] arguments, List resolveStack)
+ private (bool result, List? parameters, NoMatchingConstructorFoundException? exception) TryGetTypeResolveStack(Type type, object[]? arguments, List resolveStack)
{
- NoMatchingConstructorFoundException noMatchingConstructorFoundException = null;
+ NoMatchingConstructorFoundException? noMatchingConstructorFoundException = null;
//find best ctor
List sortedConstructors = TryGetSortedConstructors(type);
foreach (ConstructorInfo constructor in sortedConstructors)
{
- (bool result, List parameters, List exceptions) = TryGetConstructorResolveStack(constructor, arguments, resolveStack);
+ (bool result, List? parameters, List? exceptions) = TryGetConstructorResolveStack(constructor, arguments, resolveStack);
if (result)
return (true, parameters, null);
@@ -566,7 +567,7 @@ namespace LightweightIocContainer
/// parameters: The parameters needed to resolve the given
/// exception: A List of s if the constructor is not matching
///
- private (bool result, List parameters, List exceptions) TryGetConstructorResolveStack(ConstructorInfo constructor, object[] arguments, List resolveStack)
+ private (bool result, List? parameters, List? exceptions) TryGetConstructorResolveStack(ConstructorInfo constructor, object[]? arguments, List resolveStack)
{
List constructorParameters = constructor.GetParameters().ToList();
if (!constructorParameters.Any())
@@ -575,7 +576,7 @@ namespace LightweightIocContainer
List exceptions = new();
List parameters = new();
- List passedArguments = null;
+ List? passedArguments = null;
if (arguments != null)
passedArguments = new List(arguments);
@@ -602,21 +603,21 @@ namespace LightweightIocContainer
Type registeredType = GetTypeNonGeneric(parameter.ParameterType, registration);
- object singletonInstance = TryGetSingletonInstance(registeredType);
+ object? singletonInstance = TryGetSingletonInstance(registeredType);
if (singletonInstance != null)
fittingArgument = singletonInstance;
else
{
- object[] argumentsForRegistration = null;
+ object[]? argumentsForRegistration = null;
if (registration is IWithParametersInternal { Parameters: { } } registrationWithParameters)
argumentsForRegistration = UpdateArgumentsWithRegistrationParameters(registrationWithParameters, null);
- (bool result, List parametersToResolve, NoMatchingConstructorFoundException exception) =
+ (bool result, List? parametersToResolve, NoMatchingConstructorFoundException? exception) =
TryGetTypeResolveStack(registeredType, argumentsForRegistration, internalResolveStack);
if (result)
fittingArgument = new InternalToBeResolvedPlaceholder(registeredType, parametersToResolve);
- else
+ else if (exception != null)
exceptions.Add(new ConstructorNotMatchingException(constructor, exception));
}
}
@@ -648,18 +649,16 @@ namespace LightweightIocContainer
///
/// The given
/// The for the given
- [CanBeNull]
- private IRegistration FindRegistration() => FindRegistration(typeof(T));
+ private IRegistration? FindRegistration() => FindRegistration(typeof(T));
///
/// Find the for the given
///
/// The given
/// The for the given
- [CanBeNull]
- private IRegistration FindRegistration(Type type)
+ private IRegistration? FindRegistration(Type type)
{
- IRegistration registration = Registrations.FirstOrDefault(r => r.InterfaceType == type);
+ IRegistration? registration = Registrations.FirstOrDefault(r => r.InterfaceType == type);
if (registration != null)
return registration;
@@ -721,7 +720,7 @@ namespace LightweightIocContainer
/// The given
/// The new resolve stack
/// A circular dependency was detected
- private List CheckForCircularDependencies(List resolveStack) => CheckForCircularDependencies(typeof(T), resolveStack);
+ private List CheckForCircularDependencies(List? resolveStack) => CheckForCircularDependencies(typeof(T), resolveStack);
///
/// Check the given resolve stack for circular dependencies
@@ -730,7 +729,7 @@ namespace LightweightIocContainer
/// The given resolve stack
/// The new resolve stack
/// A circular dependency was detected
- private List CheckForCircularDependencies(Type type, List resolveStack)
+ private List CheckForCircularDependencies(Type type, List? resolveStack)
{
if (resolveStack == null) //first resolve call
resolveStack = new List {type}; //create new stack and add the currently resolving type to the stack
@@ -748,7 +747,7 @@ namespace LightweightIocContainer
/// The to clear the multiton instances
public void ClearMultitonInstances()
{
- IRegistration registration = FindRegistration();
+ IRegistration? registration = FindRegistration();
if (registration is not IMultitonRegistration multitonRegistration)
return;
diff --git a/LightweightIocContainer/LightweightIocContainer.csproj b/LightweightIocContainer/LightweightIocContainer.csproj
index c5ac3c9..2365683 100644
--- a/LightweightIocContainer/LightweightIocContainer.csproj
+++ b/LightweightIocContainer/LightweightIocContainer.csproj
@@ -14,6 +14,7 @@
3.0.0.0
LICENSE.md
3.0.0-beta
+ enable
diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml
index e656be4..67a2774 100644
--- a/LightweightIocContainer/LightweightIocContainer.xml
+++ b/LightweightIocContainer/LightweightIocContainer.xml
@@ -213,12 +213,11 @@
No matching constructor was found for the given or resolvable arguments
-
+
No matching constructor was found for the given or resolvable arguments
The with no matching constructor
- The inner exceptions of type
@@ -946,6 +945,14 @@
An instance of the given
Could not find function
+
+
+ Recursively resolve a with the given parameters for an
+
+ The that includes the type and resolve stack
+ The current resolve stack
+ A recursively resolved instance of the given
+
Gets an instance of a given registered
@@ -967,6 +974,13 @@
The current resolve stack
An existing or newly created singleton instance of the given
+
+
+ Try to get an existing singleton instance for a given
+
+ The given
+ A singleton instance if existing for the given , null if not
+
Gets or creates a multiton instance of a given
@@ -1007,6 +1021,90 @@
An array of all needed constructor arguments to create the
No matching constructor was found for the given or resolvable arguments
+
+
+ Try to get the resolve stack for a given
+
+ The given
+ The given arguments
+ The current resolve stack
+
+ result: True if successful, false if not
+ parameters: The parameters needed to resolve the given
+ exception: A if no matching constructor was found
+
+
+
+
+ Try to get the resolve stack for a given constructor
+
+ The for the given constructor
+ The given arguments
+ The current resolve stack
+
+ result: True if successful, false if not
+ parameters: The parameters needed to resolve the given
+ exception: A List of s if the constructor is not matching
+
+
+
+
+ Find the for the given
+
+ The given
+ The for the given
+
+
+
+ Find the for the given
+
+ The given
+ The for the given
+
+
+
+ Try to get the sorted constructors for the given
+
+ The given
+ A list of sorted for the given
+ No public constructor was found for the given
+
+
+
+ Get the implementation type for the given
+
+ The given
+ The given of the interface
+ The implementation for the given
+ Unknown passed
+
+
+
+ Non generic method to get the implementation type for the given
+
+ The given of the interface
+ The given
+ The implementation for the given
+ Unknown passed
+
+
+
+ Check the given resolve stack for circular dependencies
+
+ The given resolve stack
+ The given
+ The new resolve stack
+ A circular dependency was detected
+
+
+
+ Check the given resolve stack for circular dependencies
+
+ The given
+ The given resolve stack
+ The new resolve stack
+ A circular dependency was detected
+
Clear the multiton instances of the given from the registered multitons list
@@ -1514,6 +1612,16 @@
An internal placeholder that is used to hold types that need to be resolved during the resolving process
+
+
+ The to be resolved
+
+
+
+
+ The parameters needed to resolve the
+
+
Returns the default value for a given
diff --git a/LightweightIocContainer/Registrations/MultipleMultitonRegistration.cs b/LightweightIocContainer/Registrations/MultipleMultitonRegistration.cs
index 2792269..158f5cb 100644
--- a/LightweightIocContainer/Registrations/MultipleMultitonRegistration.cs
+++ b/LightweightIocContainer/Registrations/MultipleMultitonRegistration.cs
@@ -45,7 +45,7 @@ namespace LightweightIocContainer.Registrations
///
/// The
/// The current instance of this
- public override ITypedRegistration OnCreate(Action action)
+ public override ITypedRegistration OnCreate(Action action)
{
foreach (IRegistration registration in Registrations)
{
diff --git a/LightweightIocContainer/Registrations/MultipleRegistration.cs b/LightweightIocContainer/Registrations/MultipleRegistration.cs
index 7ccb963..b5ce902 100644
--- a/LightweightIocContainer/Registrations/MultipleRegistration.cs
+++ b/LightweightIocContainer/Registrations/MultipleRegistration.cs
@@ -24,10 +24,8 @@ namespace LightweightIocContainer.Registrations
/// The of this
/// The current instance of the
protected MultipleRegistration(Type interfaceType1, Type implementationType, Lifestyle lifestyle, IocContainer container)
- : base(interfaceType1, implementationType, lifestyle, container)
- {
-
- }
+ : base(interfaceType1, implementationType, lifestyle, container) =>
+ Registrations = new List();
///
/// A of s that are registered within this
@@ -66,7 +64,7 @@ namespace LightweightIocContainer.Registrations
///
/// The
/// The current instance of this
- public override ITypedRegistration OnCreate(Action action)
+ public override ITypedRegistration OnCreate(Action action)
{
foreach (IRegistration registration in Registrations)
{
@@ -114,7 +112,7 @@ namespace LightweightIocContainer.Registrations
///
/// The
/// The current instance of this
- public override ITypedRegistration OnCreate(Action action)
+ public override ITypedRegistration OnCreate(Action action)
{
foreach (IRegistration registration in Registrations)
{
@@ -167,7 +165,7 @@ namespace LightweightIocContainer.Registrations
///
/// The
/// The current instance of this
- public override ITypedRegistration OnCreate(Action action)
+ public override ITypedRegistration OnCreate(Action action)
{
foreach (IRegistration registration in Registrations)
{
@@ -225,7 +223,7 @@ namespace LightweightIocContainer.Registrations
///
/// The
/// The current instance of this
- public override ITypedRegistration OnCreate(Action action)
+ public override ITypedRegistration OnCreate(Action action)
{
foreach (IRegistration registration in Registrations)
{
diff --git a/LightweightIocContainer/Registrations/RegistrationBase.cs b/LightweightIocContainer/Registrations/RegistrationBase.cs
index 63481e6..7a43160 100644
--- a/LightweightIocContainer/Registrations/RegistrationBase.cs
+++ b/LightweightIocContainer/Registrations/RegistrationBase.cs
@@ -48,12 +48,12 @@ namespace LightweightIocContainer.Registrations
/// An of parameters that are used to an instance of this
/// Can be set in the by calling
///
- public object[] Parameters { get; private set; }
+ public object[]? Parameters { get; private set; }
///
/// The Factory added with the method
///
- public ITypedFactory Factory { get; private set; }
+ public ITypedFactory? Factory { get; private set; }
///
/// Pass parameters that will be used to an instance of this
diff --git a/LightweightIocContainer/Registrations/SingleTypeRegistration.cs b/LightweightIocContainer/Registrations/SingleTypeRegistration.cs
index 8ce618a..ed36d70 100644
--- a/LightweightIocContainer/Registrations/SingleTypeRegistration.cs
+++ b/LightweightIocContainer/Registrations/SingleTypeRegistration.cs
@@ -29,7 +29,7 @@ namespace LightweightIocContainer.Registrations
///
/// that is invoked instead of creating an instance of this the default way
///
- public Func FactoryMethod { get; private set; }
+ public Func? FactoryMethod { get; private set; }
///
/// Pass a that will be invoked instead of creating an instance of this the default way
diff --git a/LightweightIocContainer/Registrations/TypedRegistration.cs b/LightweightIocContainer/Registrations/TypedRegistration.cs
index a2bfa98..dc6d73d 100644
--- a/LightweightIocContainer/Registrations/TypedRegistration.cs
+++ b/LightweightIocContainer/Registrations/TypedRegistration.cs
@@ -35,22 +35,22 @@ namespace LightweightIocContainer.Registrations
/// This is invoked when an instance of this type is created.
/// Can be set in the by calling
///
- private Action OnCreateAction { get; set; }
+ private Action? OnCreateAction { get; set; }
///
/// This is invoked when an instance of this type is created.
/// Can be set in the by calling
///
- Action IOnCreate.OnCreateAction => OnCreateAction;
+ Action? IOnCreate.OnCreateAction => OnCreateAction;
///
/// Pass an that will be invoked when an instance of this type is created
///
/// The
/// The current instance of this
- public virtual ITypedRegistration OnCreate(Action action)
+ public virtual ITypedRegistration OnCreate(Action action)
{
- OnCreateAction = a => action((TImplementation) a);
+ OnCreateAction = a => action((TImplementation?) a);
return this;
}
}
diff --git a/LightweightIocContainer/ResolvePlaceholders/InternalToBeResolvedPlaceholder.cs b/LightweightIocContainer/ResolvePlaceholders/InternalToBeResolvedPlaceholder.cs
index 373dbd4..dd7ed6f 100644
--- a/LightweightIocContainer/ResolvePlaceholders/InternalToBeResolvedPlaceholder.cs
+++ b/LightweightIocContainer/ResolvePlaceholders/InternalToBeResolvedPlaceholder.cs
@@ -12,7 +12,7 @@ namespace LightweightIocContainer.ResolvePlaceholders
///
internal class InternalToBeResolvedPlaceholder
{
- public InternalToBeResolvedPlaceholder(Type resolvedType, List parameters)
+ public InternalToBeResolvedPlaceholder(Type resolvedType, List? parameters)
{
ResolvedType = resolvedType;
Parameters = parameters;
@@ -26,6 +26,6 @@ namespace LightweightIocContainer.ResolvePlaceholders
///
/// The parameters needed to resolve the
///
- public List Parameters { get; }
+ public List? Parameters { get; }
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/TypeExtension.cs b/LightweightIocContainer/TypeExtension.cs
index aae517f..b0682d7 100644
--- a/LightweightIocContainer/TypeExtension.cs
+++ b/LightweightIocContainer/TypeExtension.cs
@@ -13,6 +13,6 @@ namespace LightweightIocContainer
///
/// The given
/// The default value for the given
- 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;
}
}
\ No newline at end of file
diff --git a/LightweightIocContainer/Validation/IocValidator.cs b/LightweightIocContainer/Validation/IocValidator.cs
index 7278023..6a3026c 100644
--- a/LightweightIocContainer/Validation/IocValidator.cs
+++ b/LightweightIocContainer/Validation/IocValidator.cs
@@ -16,7 +16,7 @@ namespace LightweightIocContainer.Validation
public class IocValidator
{
private readonly IocContainer _iocContainer;
- private readonly List<(Type type, object parameter)> _parameters;
+ private readonly List<(Type type, object? parameter)> _parameters;
///
/// Validator for your to check if everything can be resolved with your current setup
@@ -25,7 +25,7 @@ namespace LightweightIocContainer.Validation
public IocValidator(IocContainer iocContainer)
{
_iocContainer = iocContainer;
- _parameters = new List<(Type, object)>();
+ _parameters = new List<(Type, object?)>();
}
///
@@ -67,7 +67,7 @@ namespace LightweightIocContainer.Validation
throw new AggregateException("Validation failed.", validationExceptions);
}
- private void TryResolve(Type type, object[] arguments, List validationExceptions)
+ private void TryResolve(Type type, object?[]? arguments, List validationExceptions)
{
try
{