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 @@ +