Files
Toolkit2/Toolkit.Foundation/ServiceScopeProvider.cs
T
TheXamlGuy bc55c4649b tidy
2024-04-26 23:05:36 +01:00

21 lines
527 B
C#

using Microsoft.Extensions.DependencyInjection;
namespace Toolkit.Foundation;
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;
}
}