Die Datei `DIExtensions.cs` wurde erheblich überarbeitet, um Abhängigkeiten von der Schicht `DigitalData.UserManager.Infrastructure` zu entfernen. Die Methode `AddUserManager` wurde vereinfacht und eine Methode `AddEncryptor` hinzugefügt. Die Projektverweise auf die Infrastrukturebene in der Anwendungsprojektdatei wurden entfernt. Aktualisierte Servicedateien zur Verwendung neuer Repository-Schnittstellen aus „DigitalData.UserManager.Application.Contracts.Repositories“. Repository-Schnittstellen wurden in den Namensraum für Anwendungsverträge verschoben und ihre Definitionen aktualisiert. Einführung von `DependencyInjection.cs` für die Handhabung von Infrastrukturdienstregistrierungen. Aktualisierte Repository-Implementierungen, um sie an die neue Struktur anzupassen, die Trennung von Belangen zu verbessern und die Injektion von Abhängigkeiten zu vereinfachen.
42 lines
2.1 KiB
C#
42 lines
2.1 KiB
C#
using DigitalData.UserManager.Application.Contracts;
|
|
using DigitalData.UserManager.Application.MappingProfiles;
|
|
using DigitalData.UserManager.Application.Services;
|
|
using DigitalData.UserManager.Application.Services.Options;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace DigitalData.UserManager.Application
|
|
{
|
|
public static class DIExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds the UserManager services and repositories to the specified <see cref="IServiceCollection"/>.
|
|
/// This method registers the necessary mappings, repositories, and services for the UserManager.
|
|
/// </summary>
|
|
/// <typeparam name="TDbContext">The type of the DbContext to use for the repositories.</typeparam>
|
|
/// <param name="services">The IServiceCollection to which the services will be added.</param>
|
|
/// <returns>The updated IServiceCollection.</returns>
|
|
public static IServiceCollection AddUserManager(this IServiceCollection services)
|
|
=> 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<IUserService, UserService>()
|
|
.AddScoped<IGroupService, GroupService>()
|
|
.AddScoped<IGroupOfUserService, GroupOfUserService>()
|
|
.AddScoped<IModuleService, ModuleService>()
|
|
.AddScoped<IModuleOfUserService, ModuleOfUserService>()
|
|
.AddScoped<IUserRepService, UserRepService>();
|
|
|
|
public static IServiceCollection AddEncryptor(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
services.AddSingleton<Encryptor>();
|
|
services.Configure<EncryptionParameters>(configuration);
|
|
return services;
|
|
}
|
|
}
|
|
} |