Skip to content

Commit 1946322

Browse files
committed
Use actual service provider for scoped Get
1 parent 850728e commit 1946322

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

StabilityMatrix.Avalonia/Services/ScopedServiceManager.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace StabilityMatrix.Avalonia.Services;
1+
using Microsoft.Extensions.DependencyInjection;
2+
3+
namespace StabilityMatrix.Avalonia.Services;
24

35
internal class ScopedServiceManager<T> : IServiceManager<T>
46
{
@@ -78,6 +80,13 @@ public T Get(Type serviceType)
7880

7981
// 3. If not scoped, delegate to the parent manager to resolve Singleton or Transient
8082
// (Parent's Get will throw if the type isn't registered there either)
81-
return parentManager.Get(serviceType);
83+
// return parentManager.Get(serviceType);
84+
85+
// We don't use parent manager for scoped contexts anymore,
86+
// since we'll lose the scope through transients,
87+
// then we have to make Inference Cards scoped as well,
88+
// which cases samplers to be shared with Civit page and other issues.
89+
// 3. Just use the scoped service provider, since we might need to keep the scope through transients as well
90+
return (T)scopedServiceProvider.GetRequiredService(serviceType);
8291
}
8392
}

0 commit comments

Comments
 (0)