Renamed namespaces and projects from DocumentOperator to DocumentService, updating all references accordingly. Refactored PdfSignatureAppearanceDto and related enums to use properties with init accessors for improved clarity. Removed and re-added IPkcs11SelfTestStatusProvider with updated namespace. Simplified dependency injection by removing DocumentOperatorApplication registration. Updated appsettings.json with a specific AssetsRootPath. Incremented version numbers in project files for a new release. Introduced PdfSignatureClient and IPdfSignatureClient for PDF digital-signing operations. Updated project files to use newer Microsoft.Extensions package versions. Removed all DocumentOperator references, completing the transition to DocumentService. Added new DTOs and enums for PDF signature options and appearance.
71 lines
2.8 KiB
C#
71 lines
2.8 KiB
C#
using DocumentService.Client.Clients;
|
||
using DocumentService.Client.Configuration;
|
||
using DocumentService.Client.Interfaces;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
using System.Net;
|
||
using System.Net.Http;
|
||
|
||
namespace DocumentService.Client.Extensions;
|
||
|
||
/// <summary>
|
||
/// Extension methods for registering DocumentService clients in DI container.
|
||
/// </summary>
|
||
public static class ServiceCollectionExtensions
|
||
{
|
||
/// <summary>
|
||
/// Registers all six DocumentService HTTP clients as Scoped via HttpClientFactory.
|
||
/// </summary>
|
||
/// <param name="services">Service collection</param>
|
||
/// <param name="configureOptions">Configuration action for client options</param>
|
||
/// <returns>Service collection for chaining</returns>
|
||
public static IServiceCollection AddDocumentServiceClients(
|
||
this IServiceCollection services,
|
||
Action<DocumentServiceClientOptions> configureOptions)
|
||
{
|
||
services.Configure(configureOptions);
|
||
|
||
var options = new DocumentServiceClientOptions();
|
||
configureOptions(options);
|
||
|
||
var configureHandler = () => new HttpClientHandler
|
||
{
|
||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
|
||
};
|
||
|
||
void ConfigureClient(System.Net.Http.HttpClient client)
|
||
{
|
||
client.BaseAddress = new Uri(options.BaseUrl);
|
||
client.Timeout = options.Timeout;
|
||
}
|
||
|
||
services.AddHttpClient<IPdfValidationClient, PdfValidationClient>(ConfigureClient)
|
||
.ConfigurePrimaryHttpMessageHandler(configureHandler);
|
||
|
||
services.AddHttpClient<IPdfAttachmentClient, PdfAttachmentClient>(ConfigureClient)
|
||
.ConfigurePrimaryHttpMessageHandler(configureHandler);
|
||
|
||
services.AddHttpClient<IPdfOperationsClient, PdfOperationsClient>(ConfigureClient)
|
||
.ConfigurePrimaryHttpMessageHandler(configureHandler);
|
||
|
||
services.AddHttpClient<ISwissQrCodeClient, SwissQrCodeClient>(ConfigureClient)
|
||
.ConfigurePrimaryHttpMessageHandler(configureHandler);
|
||
|
||
services.AddHttpClient<IZugferdClient, ZugferdClient>(ConfigureClient)
|
||
.ConfigurePrimaryHttpMessageHandler(configureHandler);
|
||
|
||
services.AddHttpClient<IPdfSignatureClient, PdfSignatureClient>(ConfigureClient)
|
||
.ConfigurePrimaryHttpMessageHandler(configureHandler);
|
||
|
||
// Conversion client is registered but all methods throw NotImplementedException
|
||
// until the server-side endpoints are ready.
|
||
services.AddHttpClient<IPdfConversionClient, PdfConversionClient>(ConfigureClient)
|
||
.ConfigurePrimaryHttpMessageHandler(configureHandler);
|
||
|
||
// WorkflowsClient composes existing clients – no HttpClient needed.
|
||
services.AddScoped<IWorkflowsClient, WorkflowsClient>();
|
||
|
||
return services;
|
||
}
|
||
}
|
||
|