From 725b186db6b021275c1dbc150ee3703e965deff3 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 15 Jan 2025 17:22:14 +0100 Subject: [PATCH] =?UTF-8?q?refactor(DIExtensions):=20AddDirectorySearchSer?= =?UTF-8?q?vice-Methode=20entfernt=20und=20AddDirectorySearchService=20akt?= =?UTF-8?q?ualisiert,=20um=20=C3=BCber=20Konfigurationseinstellungen=20kon?= =?UTF-8?q?figuriert=20werden=20zu=20k=C3=B6nnen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DigitalData.Core.Application/DIExtensions.cs | 57 ++----------------- .../DigitalData.Core.Application.csproj | 1 + 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/DigitalData.Core.Application/DIExtensions.cs b/DigitalData.Core.Application/DIExtensions.cs index 3d8b4b5..49a30e7 100644 --- a/DigitalData.Core.Application/DIExtensions.cs +++ b/DigitalData.Core.Application/DIExtensions.cs @@ -1,7 +1,5 @@ -using AutoMapper; -using DigitalData.Core.Abstractions; -using DigitalData.Core.Abstractions.Application; -using DigitalData.Core.Abstractions.Infrastructure; +using DigitalData.Core.Abstractions.Application; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; @@ -13,50 +11,6 @@ namespace DigitalData.Core.Application /// public static class DIExtensions { - /// - /// Adds a basic CRUD service for a specific DTO and entity type to the service collection. - /// - /// The DTO type the service operates on. - /// The entity type corresponding to the DTO. - /// The type of the entity's identifier. - /// The AutoMapper profile type for configuring mappings between the DTO and the entity. - /// The to add the service to. - /// An optional action to configure additional services for the CRUD service. - /// The original instance, allowing further configuration. - public static IServiceCollection AddCleanBasicCRUDService(this IServiceCollection services, Action? configureService = null) - where TCRUDRepository : ICRUDRepository where TDto : class, IUnique where TEntity : class, IUnique where TProfile : Profile - { - services.AddScoped, BasicCRUDService>(); - configureService?.Invoke(services); - - services.AddAutoMapper(typeof(TProfile).Assembly); - - return services; - } - - /// - /// Adds a CRUD service for managing create, read, update, and delete operations for a specific set of DTOs and an entity type to the service collection. - /// - /// The repository type that provides CRUD operations for entities of type TEntity. - /// The DTO type used for create operations. - /// The DTO type used for read operations. - /// The entity type corresponding to the DTOs. - /// The type of the entity's identifier. - /// The AutoMapper profile type for configuring mappings between the DTOs and the entity. - /// The to add the service to. - /// An optional action to configure additional services for the CRUD service. - /// The original instance, allowing further configuration. - public static IServiceCollection AddCleanCRUDService(this IServiceCollection services, Action? configureService = null) - where TCRUDRepository : ICRUDRepository where TCreateDto : class where TReadDto : class, IUnique where TEntity : class, IUnique where TProfile : Profile - { - services.AddScoped, CRUDService>(); - configureService?.Invoke(services); - - services.AddAutoMapper(typeof(TProfile).Assembly); - - return services; - } - /// /// Adds the directory search service to the . /// @@ -71,12 +25,9 @@ namespace DigitalData.Core.Application /// If is not provided, ensure to configure the options separately /// using the pattern. /// - public static IServiceCollection AddDirectorySearchService(this IServiceCollection service, DirectorySearchOptions? directorySearchOptions = null) + public static IServiceCollection AddDirectorySearchService(this IServiceCollection service, IConfigurationSection directorySearchOptions) { - if(directorySearchOptions is not null) - service.AddSingleton(Options.Create(directorySearchOptions)); - - return service + return service.Configure(directorySearchOptions) .AddMemoryCache() .AddScoped(); } diff --git a/DigitalData.Core.Application/DigitalData.Core.Application.csproj b/DigitalData.Core.Application/DigitalData.Core.Application.csproj index 9391841..ef70af7 100644 --- a/DigitalData.Core.Application/DigitalData.Core.Application.csproj +++ b/DigitalData.Core.Application/DigitalData.Core.Application.csproj @@ -32,6 +32,7 @@ +