Files
Hyperbar/Hyperbar/Lifecycles/ServiceScopeProvider.cs
T
2024-01-14 20:35:38 +00:00

22 lines
519 B
C#

using Microsoft.Extensions.DependencyInjection;
namespace Hyperbar;
public class ServiceScopeProvider<TService>(ICache<TService, IServiceScope> cache) :
IServiceScopeProvider<TService>
where TService : notnull
{
public bool TryGet(TService service,
out IServiceScope? serviceScope)
{
if (cache.TryGetValue(service, out IServiceScope? value))
{
serviceScope = value;
return true;
}
serviceScope = null;
return false;
}
}