using System.IdentityModel.Tokens.Jwt; using ApplicationLayer.InfrastructureServicesInterfaces; using Microsoft.Extensions.DependencyInjection; namespace Infrastructure.Auth; public static class ServiceCollectionExtensions { public static IServiceCollection AddTokenGenerator(this IServiceCollection services, TokenGeneratorOptions options) { services.AddSingleton(); services.AddSingleton(provider => { var tokenHandler = provider.GetRequiredService(); var dateTimeProvider = provider.GetRequiredService(); return new TokenGenerator(options, tokenHandler, dateTimeProvider); }); return services; } }