Developer 02 3a1aeb7ac3 Refactor namespaces and enhance application structure
This commit reorganizes namespaces from `DigitalData.Core.Abstractions` and `DigitalData.Core.DTO` to `DigitalData.Core.Application.Interfaces` and `DigitalData.Core.Application.DTO`, improving maintainability and clarity.

Updated using directives across multiple files to reflect the new structure, ensuring functionality remains intact.

Project references in `DigitalData.Core.API.csproj` have been consolidated to include the new Application project.

Introduced new classes and interfaces such as `BaseDTO`, `CookieConsentSettings`, `DataResult`, `Notice`, and `Result` to enhance data transfer and service result handling.

Updated `IRepository`, `ICRUDRepository`, and `IEntityMapper` interfaces to facilitate CRUD operations and entity mapping.

Added extension methods in `Extensions.cs` to improve repository usability.

New interfaces for HTTP client services have been added, enhancing external API call handling.

Overall, these changes reflect a significant restructuring aimed at improving organization and preparing for future development.
2025-05-16 11:24:58 +02:00

37 lines
1.7 KiB
C#

using DigitalData.Core.Client.Interface;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using System.Net;
//TODO: Update to use IHttpClientFactory (see also: https://learn.microsoft.com/tr-tr/dotnet/core/extensions/httpclient-factory)
namespace DigitalData.Core.Client
{
public static class DIExtensions
{
internal static IServiceCollection AddHttpClientServiceDefaults(this IServiceCollection services)
{
services.TryAddSingleton<HttpClient>();
services.TryAddSingleton<CookieContainer>();
return services;
}
public static IServiceCollection AddHttpClientService<THttpClientOptions>(this IServiceCollection services, IConfigurationSection section)
where THttpClientOptions : class, IHttpClientOptions
{
services.AddHttpClientServiceDefaults();
services.TryAddSingleton<IHttpClientService<THttpClientOptions>, HttpClientService<THttpClientOptions>>();
return services.Configure<THttpClientOptions>(section);
}
public static IServiceCollection AddHttpClientService<THttpClientOptions>(this IServiceCollection services, THttpClientOptions options)
where THttpClientOptions : class, IHttpClientOptions
{
services.AddHttpClientServiceDefaults();
services.TryAddSingleton<IHttpClientService<THttpClientOptions>, HttpClientService<THttpClientOptions>>();
services.TryAddSingleton(Options.Create(options));
return services;
}
}
}