diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index abb5a1a..580f6c1 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -167,9 +167,13 @@ public class IocContainer : IIocContainer, IIocResolver if (registration is IWithParametersInternal { Parameters: { } } registrationWithParameters) arguments = UpdateArgumentsWithRegistrationParameters(registrationWithParameters, arguments); + List? resolveArguments = arguments?.ToList(); + if (resolveArguments != null && registration is IMultitonRegistration) + resolveArguments.RemoveAt(0); //remove scope argument for multitions + Type registeredType = GetType(registration); (bool result, List? parametersToResolve, NoMatchingConstructorFoundException? exception) = - TryGetTypeResolveStack(registeredType, arguments, internalResolveStack); + TryGetTypeResolveStack(registeredType, resolveArguments, internalResolveStack); if (registration is IMultitonRegistration multitonRegistration) { @@ -450,7 +454,7 @@ public class IocContainer : IIocContainer, IIocResolver /// 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, IReadOnlyCollection? arguments, List resolveStack) { NoMatchingConstructorFoundException? noMatchingConstructorFoundException = null; @@ -481,7 +485,7 @@ public class IocContainer : IIocContainer, IIocResolver /// 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, IReadOnlyCollection? arguments, List resolveStack) { List constructorParameters = constructor.GetParameters().ToList(); diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml index 60272ca..a69e5b6 100644 --- a/LightweightIocContainer/LightweightIocContainer.xml +++ b/LightweightIocContainer/LightweightIocContainer.xml @@ -1107,7 +1107,7 @@ The constructor arguments The argument list updated with the - + Try to get the resolve stack for a given @@ -1120,7 +1120,7 @@ exception: A if no matching constructor was found - + Try to get the resolve stack for a given constructor