using DigitalData.UserManager.Application.Contracts;
using DigitalData.UserManager.Application.MappingProfiles;
using DigitalData.UserManager.Application.Services;
using DigitalData.UserManager.Application.Services.Options;
using DigitalData.UserManager.Infrastructure.Contracts;
using DigitalData.UserManager.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace DigitalData.UserManager.Application
{
public static class DIExtensions
{
///
/// Adds the UserManager services and repositories to the specified .
/// This method registers the necessary mappings, repositories, and services for the UserManager.
///
/// The type of the DbContext to use for the repositories.
/// The IServiceCollection to which the services will be added.
/// The updated IServiceCollection.
public static IServiceCollection AddUserManager(this IServiceCollection services)
where TDbContext : DbContext, IUserManagerDbContext
=> services
.AddAutoMapper(typeof(UserMappingProfile).Assembly)
.AddAutoMapper(typeof(GroupMappingProfile).Assembly)
.AddAutoMapper(typeof(GroupOfUserMappingProfile).Assembly)
.AddAutoMapper(typeof(ModuleMappingProfile).Assembly)
.AddAutoMapper(typeof(ModuleOfUserMappingProfile).Assembly)
.AddAutoMapper(typeof(UserRepMappingProfile).Assembly)
.AddScoped>()
.AddScoped>()
.AddScoped>()
.AddScoped>()
.AddScoped>()
.AddScoped>()
.AddScoped>()
.AddScoped()
.AddScoped()
.AddScoped()
.AddScoped()
.AddScoped()
.AddScoped();
///
/// Adds the UserManager services and repositories to the specified .
/// This method registers the necessary mappings, repositories, services and for the UserManager.
///
/// The IServiceCollection to which the services will be added.
/// The updated IServiceCollection.
public static IServiceCollection AddUserManager(this IServiceCollection services, string connectionString)=> services
.AddDbContext(options => options.UseSqlServer(connectionString).EnableSensitiveDataLogging())
.AddUserManager();
public static IServiceCollection AddEncryptor(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton();
services.Configure(configuration);
return services;
}
}
}