using Helpdesk.Application.Abstractions; using Helpdesk.Application.Issues; using Helpdesk.Infrastructure.Background; using Helpdesk.Infrastructure.Email; using Helpdesk.Infrastructure.Files; using Helpdesk.Infrastructure.Persistence; using Helpdesk.Infrastructure.Security; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace Helpdesk.Infrastructure; public static class DependencyInjection { public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration) { var connectionString = configuration.GetConnectionString("Helpdesk") ?? throw new InvalidOperationException("Chybí připojovací řetězec ConnectionStrings:Helpdesk."); services.AddSingleton(TimeProvider.System); services.Configure(configuration.GetSection(JwtOptions.Section)); services.Configure(configuration.GetSection(EncryptionOptions.Section)); services.AddSingleton(); services.AddSingleton(); services.AddDbContext((sp, options) => options .UseMySql(connectionString, new MariaDbServerVersion(new Version(11, 4))) .UseSnakeCaseNamingConvention() .AddInterceptors(sp.GetRequiredService())); services.AddScoped(sp => sp.GetRequiredService()); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddHostedService(); services.AddHostedService(); services.AddHostedService(); return services; } }