mirror of
https://github.com/AlexMacocian/Slim.git
synced 2026-07-15 15:19:59 +00:00
Bugfix for factory propagations
This commit is contained in:
@@ -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<IServiceProvider, object>((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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -8,10 +8,10 @@
|
||||
<Company />
|
||||
<Product></Product>
|
||||
<Description>Service lifetime management and dependency injection framework.</Description>
|
||||
<AssemblyVersion>1.11.0</AssemblyVersion>
|
||||
<FileVersion>1.11.0</FileVersion>
|
||||
<AssemblyVersion>1.11.1</AssemblyVersion>
|
||||
<FileVersion>1.11.1</FileVersion>
|
||||
<PackageProjectUrl>https://github.com/AlexMacocian/Slim</PackageProjectUrl>
|
||||
<Version>1.11.0</Version>
|
||||
<Version>1.11.1</Version>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
|
||||
Reference in New Issue
Block a user