diff --git a/Slim/ServiceManager.cs b/Slim/ServiceManager.cs index ba48833..c4c6909 100644 --- a/Slim/ServiceManager.cs +++ b/Slim/ServiceManager.cs @@ -925,8 +925,17 @@ public sealed class ServiceManager : IServiceManager */ foreach (var kvp in this.InterfaceMapping) { + if (kvp.Value.Count is 0) + { + continue; + } + foreach(var registration in kvp.Value) { + /* + * Singletons reference the original service manager while + * scoped or transient will reference the original factories. + */ if (registration.Item2 is Lifetime.Singleton) { if (!factories.TryGetValue(kvp.Key, out var factoryRegistrations) || @@ -938,6 +947,20 @@ public sealed class ServiceManager : IServiceManager factoryRegistrations.Add(new Func((scopedManager) => this.ResolveSingletonWithScopedManager((ServiceManager)scopedManager, kvp.Key, registration.Item1))); } + else if (this.Factories.TryGetValue(kvp.Key, out var originalFactories)) + { + if (!factories.TryGetValue(kvp.Key, out var factoryRegistrations) || + factoryRegistrations is null) + { + factoryRegistrations = []; + factories[kvp.Key] = factoryRegistrations; + } + + foreach(var factory in originalFactories) + { + factoryRegistrations.Add(factory); + } + } } } diff --git a/Slim/Slim.csproj b/Slim/Slim.csproj index 130d98b..ea330b3 100644 --- a/Slim/Slim.csproj +++ b/Slim/Slim.csproj @@ -8,10 +8,10 @@ Service lifetime management and dependency injection framework. - 1.11.0 - 1.11.0 + 1.11.1 + 1.11.1 https://github.com/AlexMacocian/Slim - 1.11.0 + 1.11.1 true true LICENSE