diff --git a/DigitalData.UserManager.Application/DIExtensions.cs b/DigitalData.UserManager.Application/DIExtensions.cs index 0b96ddf..253dd74 100644 --- a/DigitalData.UserManager.Application/DIExtensions.cs +++ b/DigitalData.UserManager.Application/DIExtensions.cs @@ -16,7 +16,7 @@ namespace DigitalData.UserManager.Application /// 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) + public static IServiceCollection AddUserManagerApplication(this IServiceCollection services) => services .AddAutoMapper(typeof(UserMappingProfile).Assembly) .AddAutoMapper(typeof(GroupMappingProfile).Assembly) diff --git a/DigitalData.UserManager.DependencyInjection/DigitalData.UserManager.DependencyInjection.csproj b/DigitalData.UserManager.DependencyInjection/DigitalData.UserManager.DependencyInjection.csproj index 9ba033b..0c14929 100644 --- a/DigitalData.UserManager.DependencyInjection/DigitalData.UserManager.DependencyInjection.csproj +++ b/DigitalData.UserManager.DependencyInjection/DigitalData.UserManager.DependencyInjection.csproj @@ -18,4 +18,10 @@ 1.0.0 + + + + + + diff --git a/DigitalData.UserManager.DependencyInjection/Extensions.cs b/DigitalData.UserManager.DependencyInjection/Extensions.cs new file mode 100644 index 0000000..f6b17d3 --- /dev/null +++ b/DigitalData.UserManager.DependencyInjection/Extensions.cs @@ -0,0 +1,33 @@ +using DigitalData.UserManager.Application; +using DigitalData.UserManager.Infrastructure; +using DigitalData.UserManager.Infrastructure.Contracts; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; + +namespace DigitalData.UserManager.DependencyInjection; + +public static class Extensions +{ + public static IServiceCollection AddUserManager(this IServiceCollection services) + where TDbContext : DbContext, IUserManagerDbContext + { + services.AddUserManagerInfrastructure(); + services.AddUserManagerApplication(); + return services; + } + + public static IServiceCollection AddUserManager(this IServiceCollection services, Action optionsAction) + { + services.AddUserManagerInfrastructure(optionsAction); + services.AddUserManagerApplication(); + return services; + } + + public static IServiceCollection AddUserManager(this IServiceCollection services, string connectionString) + where TDbContext : DbContext, IUserManagerDbContext + { + services.AddUserManagerInfrastructure(connectionString); + services.AddUserManagerApplication(); + return services; + } +} diff --git a/DigitalData.UserManager.Infrastructure/DependencyInjection.cs b/DigitalData.UserManager.Infrastructure/DependencyInjection.cs index 4a66700..cbcf498 100644 --- a/DigitalData.UserManager.Infrastructure/DependencyInjection.cs +++ b/DigitalData.UserManager.Infrastructure/DependencyInjection.cs @@ -16,7 +16,7 @@ public static class DependencyInjection /// 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 AddInfrastructureServices(this IServiceCollection services) + public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services) where TDbContext : DbContext, IUserManagerDbContext { return services @@ -36,9 +36,9 @@ public static class DependencyInjection /// The to which the services will be added. /// An to configure the . /// The updated . - public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, Action optionsAction) => services + public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services, Action optionsAction) => services .AddDbContext(optionsAction) - .AddInfrastructureServices(); + .AddUserManagerInfrastructure(); /// /// Adds the UserManager services and repositories to the specified . @@ -46,6 +46,6 @@ public static class DependencyInjection /// /// The IServiceCollection to which the services will be added. /// The updated IServiceCollection. - public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, string connectionString) => services - .AddInfrastructureServices(options => options.UseSqlServer(connectionString).EnableSensitiveDataLogging()); + public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services, string connectionString) => services + .AddUserManagerInfrastructure(options => options.UseSqlServer(connectionString).EnableSensitiveDataLogging()); }