using Microsoft.Extensions.DependencyInjection; namespace DispenserCommon.Lazy; public static class IServiceCollectionExtendtions { public static IServiceCollection AddLazyResolution(this IServiceCollection services) { return services.AddTransient( typeof(Lazy<>), typeof(LazilyResolved<>)); } private class LazilyResolved : Lazy { public LazilyResolved(IServiceProvider serviceProvider) : base(serviceProvider.GetRequiredService) { } } }