using Core.Db; using Microsoft.EntityFrameworkCore; using System.Reflection; using AutoMapper; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; namespace Api.Start { public static class DI { public static void RegisterDependencies(this IServiceCollection services, IConfiguration configuration) { services.AddDbContext(options => options.UseSqlServer(configuration.GetConnectionString("PanakContext"))); services.AddScoped(); services.Scan(scan => scan .FromAssemblies(typeof(Services.Identity.IAuthService).GetTypeInfo().Assembly) .AddClasses() .AsImplementedInterfaces() .WithScopedLifetime()); services.AddSingleton(); var mapperConfig = new MapperConfiguration(mc => { mc.AddProfile(new AutoMapperConfig()); }); var mapper = mapperConfig.CreateMapper(); services.AddSingleton(mapper); } } }