refactor(Application.Abstractions): umbenennen in Abstractions.Application
This commit is contained in:
34
DigitalData.Core.Abstraction.Application/DTO/DIExtensions.cs
Normal file
34
DigitalData.Core.Abstraction.Application/DTO/DIExtensions.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Configuration;
|
||||
|
||||
namespace DigitalData.Core.Abstraction.Application.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for dependency injection.
|
||||
/// </summary>
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static class DIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds the <see cref="CookieConsentSettings"/> to the service collection.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to add the settings to.</param>
|
||||
/// <returns>The updated service collection.</returns>
|
||||
/// <exception cref="ConfigurationErrorsException">
|
||||
/// Thrown if the 'CookieConsentSettings' section is missing or improperly configured in appsettings.json.
|
||||
/// </exception>
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public static IServiceCollection AddCookieConsentSettings(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(sp =>
|
||||
{
|
||||
var configuration = sp.GetRequiredService<IConfiguration>();
|
||||
var settings = configuration.GetSection("CookieConsentSettings").Get<CookieConsentSettings>();
|
||||
return settings is null
|
||||
? throw new ConfigurationErrorsException("The 'CookieConsentSettings' section is missing or improperly configured in appsettings.json.")
|
||||
: settings;
|
||||
});
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user