From 88c04c23144ab2a85ab6b9c9d8be987c828ac94b Mon Sep 17 00:00:00 2001 From: Simon G Date: Mon, 5 Sep 2022 12:40:13 +0200 Subject: [PATCH] - use tryGetMultitonScopeArgument method to throw exception earlier --- LightweightIocContainer/IocContainer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index 580f6c1..7124db7 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -168,8 +168,11 @@ public class IocContainer : IIocContainer, IIocResolver arguments = UpdateArgumentsWithRegistrationParameters(registrationWithParameters, arguments); List? resolveArguments = arguments?.ToList(); - if (resolveArguments != null && registration is IMultitonRegistration) - resolveArguments.RemoveAt(0); //remove scope argument for multitions + if (resolveArguments != null && registration is IMultitonRegistration multitonReg) //remove scope argument for multitions + { + object multitonScopeArgument = TryGetMultitonScopeArgument(multitonReg, resolveArguments); + resolveArguments.Remove(multitonScopeArgument); + } Type registeredType = GetType(registration); (bool result, List? parametersToResolve, NoMatchingConstructorFoundException? exception) =