feat: DirectorySearchOptions-Klasse hinzugefügt und DirectorySearchService refaktoriert, um IOptions für eine verbesserte Konfigurationsverwaltung zu verwenden.
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Contracts.Application;
|
||||
using DigitalData.Core.Contracts.Infrastructure;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Configuration;
|
||||
|
||||
namespace DigitalData.Core.Application
|
||||
{
|
||||
@@ -58,11 +57,28 @@ namespace DigitalData.Core.Application
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddDirectorySearchService(this IServiceCollection service)
|
||||
/// <summary>
|
||||
/// Adds the directory search service to the <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
/// <param name="service">The <see cref="IServiceCollection"/> to add services to.</param>
|
||||
/// <param name="directorySearchOptions">
|
||||
/// Optional. An instance of <see cref="DirectorySearchOptions"/> to configure the directory search service.
|
||||
/// If not provided, the options need to be configured separately.
|
||||
/// </param>
|
||||
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
||||
/// <remarks>
|
||||
/// This method adds the necessary services for directory search functionality, including memory caching.
|
||||
/// If <paramref name="directorySearchOptions"/> is not provided, ensure to configure the options separately
|
||||
/// using the <see cref="IOptions{TOptions}"/> pattern.
|
||||
/// </remarks>
|
||||
public static IServiceCollection AddDirectorySearchService(this IServiceCollection service, DirectorySearchOptions? directorySearchOptions = null)
|
||||
{
|
||||
service.AddMemoryCache();
|
||||
service.AddScoped<IDirectorySearchService, DirectorySearchService>();
|
||||
return service;
|
||||
if(directorySearchOptions is not null)
|
||||
service.AddSingleton(Options.Create(directorySearchOptions));
|
||||
|
||||
return service
|
||||
.AddMemoryCache()
|
||||
.AddScoped<IDirectorySearchService, DirectorySearchService>();
|
||||
}
|
||||
|
||||
public static IServiceCollection AddJWTService<TClaimValue>(this IServiceCollection services, Func<TClaimValue, SecurityTokenDescriptor> tokenDescriptorFactory)
|
||||
|
||||
Reference in New Issue
Block a user