From 865f36d0a76b00c6014dff039ed81493b249bf0d Mon Sep 17 00:00:00 2001 From: Simon G Date: Thu, 19 Nov 2020 13:38:55 +0100 Subject: [PATCH] #45: clearMultitonInstances() gets registration first now --- LightweightIocContainer/IocContainer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index cb64982..57c2e84 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -611,7 +611,11 @@ namespace LightweightIocContainer /// The to clear the multiton instances public void ClearMultitonInstances() { - var multitonInstance = _multitons.FirstOrDefault(m => m.type == typeof(T)); + IRegistration registration = FindRegistration(); + if (!(registration is IMultitonRegistration multitonRegistration)) + return; + + var multitonInstance = _multitons.FirstOrDefault(m => m.type == multitonRegistration.ImplementationType); //it is allowed to clear a non existing multiton instance (don't throw an exception) if (multitonInstance == default)