using DigitalData.Core.Abstractions.Application;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
namespace DigitalData.Core.Application
{
///
/// Provides extension methods to for registering Clean Architecture CRUD related services and repositories.
///
public static class DIExtensions
{
///
/// Adds the directory search service to the .
///
/// The to add services to.
///
/// Optional. An instance of to configure the directory search service.
/// If not provided, the options need to be configured separately.
///
/// The updated .
///
/// This method adds the necessary services for directory search functionality, including memory caching.
/// If is not provided, ensure to configure the options separately
/// using the pattern.
///
public static IServiceCollection AddDirectorySearchService(this IServiceCollection service, IConfigurationSection directorySearchOptions)
{
return service.Configure(directorySearchOptions)
.AddMemoryCache()
.AddScoped();
}
///
/// Adds the JWT service to the .
///
/// The type of the claim value used in the JWT token.
/// The to add the service to.
/// A function that takes a claim value of type and returns a used to configure the JWT token.
/// The original instance, allowing further configuration.
///
/// This method adds the necessary services for handling JWT tokens. The function is used to generate the which is essential for creating the JWT tokens.
///
public static IServiceCollection AddJWTService(this IServiceCollection services, Func tokenDescriptorFactory)
{
return services.AddScoped, JWTService>(provider => new (tokenDescriptorFactory));
}
}
}