using HN.Application; using HN.Domain; using HN.Infrastructure.Behaviors; using HN.Infrastructure.Repositories; using MediatR; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace HN.Infrastructure { public sealed class HNServicesBuilder { private readonly IServiceCollection _services; internal HNServicesBuilder(IServiceCollection services) { _services = services; } public void ResolveConnectedUserWith() where TExecutingUserProvider : class, IExecutingUserProvider { _services.AddScoped(); } } public static class ServiceCollectionExtensions { public static HNServicesBuilder AddHN(this IServiceCollection services, IConfiguration configuration) { services.AddDbContext(options => options.UseSqlite(configuration.GetConnectionString("Default"))); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(typeof(IPipelineBehavior<,>), typeof(UnitOfWorkBehavior<,>)); services.AddMediatR(typeof(HN.Application.IHNContext)); return new HNServicesBuilder(services); } } }