using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using SPMS.Application.Interfaces; using SPMS.Domain.Interfaces; using SPMS.Infrastructure.Auth; using SPMS.Infrastructure.Persistence; using SPMS.Infrastructure.Persistence.Repositories; using SPMS.Infrastructure.Security; using SPMS.Infrastructure.Services; namespace SPMS.Infrastructure; public static class DependencyInjection { public static IServiceCollection AddInfrastructure( this IServiceCollection services, IConfiguration configuration) { // DbContext var connectionString = configuration.GetConnectionString("DefaultConnection"); services.AddDbContext(options => options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString))); // UnitOfWork & Repositories services.AddScoped(); services.AddScoped(typeof(IRepository<>), typeof(Repository<>)); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); // External Services services.AddScoped(); services.AddSingleton(); services.AddSingleton(); // Token Store & Email Service services.AddMemoryCache(); services.AddSingleton(); services.AddSingleton(); return services; } }