chore: Refactor project structure and update DI setup

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.
This commit is contained in:
Developer 02
2025-04-16 11:02:44 +02:00
parent 239a5708a7
commit 2d792c8544
32 changed files with 226 additions and 201 deletions

View File

@@ -2,9 +2,6 @@
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;
@@ -19,8 +16,7 @@ namespace DigitalData.UserManager.Application
/// <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<TDbContext>(this IServiceCollection services)
where TDbContext : DbContext, IUserManagerDbContext
public static IServiceCollection AddUserManager(this IServiceCollection services)
=> services
.AddAutoMapper(typeof(UserMappingProfile).Assembly)
.AddAutoMapper(typeof(GroupMappingProfile).Assembly)
@@ -29,31 +25,13 @@ namespace DigitalData.UserManager.Application
.AddAutoMapper(typeof(ModuleOfUserMappingProfile).Assembly)
.AddAutoMapper(typeof(UserRepMappingProfile).Assembly)
.AddScoped<IUserRepository, UserRepository<TDbContext>>()
.AddScoped<IGroupRepository, GroupRepository<TDbContext>>()
.AddScoped<IGroupOfUserRepository, GroupOfUserRepository<TDbContext>>()
.AddScoped<IModuleRepository, ModuleRepository<TDbContext>>()
.AddScoped<IModuleOfUserRepository, ModuleOfUserRepository<TDbContext>>()
.AddScoped<IUserRepRepository, UserRepRepository<TDbContext>>()
.AddScoped<IClientUserRepository, ClientUserRepository<TDbContext>>()
.AddScoped<IUserService, UserService>()
.AddScoped<IGroupService, GroupService>()
.AddScoped<IGroupOfUserService, GroupOfUserService>()
.AddScoped<IModuleService, ModuleService>()
.AddScoped<IModuleOfUserService, ModuleOfUserService>()
.AddScoped<IUserRepService, UserRepService>();
/// <summary>
/// Adds the UserManager services and repositories to the specified <see cref="IServiceCollection"/>.
/// This method registers the necessary mappings, repositories, services and <see cref="UserManagerDbContext"/> for the UserManager.
/// </summary>
/// <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, string connectionString)=> services
.AddDbContext<UserManagerDbContext>(options => options.UseSqlServer(connectionString).EnableSensitiveDataLogging())
.AddUserManager<UserManagerDbContext>();
public static IServiceCollection AddEncryptor(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton<Encryptor>();