Files
EnvelopeGenerator/EnvelopeGenerator.ServiceHost/Extensions/DependencyInjection.cs
TekH cb7d154f64 Refactor LicenseManager registration with factory
Replaces transient LicenseManager registration (with per-injection license key retrieval via MediatR) with a singleton LicenseManagerFactory. This centralizes license management and may improve performance and maintainability.
2026-04-14 21:05:21 +02:00

34 lines
1.3 KiB
C#

using EnvelopeGenerator.ServiceHost.Jobs;
using EnvelopeGenerator.ServiceHost.Jobs.FinalizeDocument;
using GdPicture14;
using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.ServiceHost.Extensions;
public static class DependencyInjection
{
[Obsolete("Check obsoleted services")]
public static IServiceCollection AddFinalizeDocumentJob(this IServiceCollection services, IConfiguration configuration)
{
services.Configure<WorkerOptions>(configuration.GetSection("Worker"));
services.AddSingleton(provider =>
{
var options = provider.GetRequiredService<IOptions<WorkerOptions>>().Value;
var manager = new JobStateManager(options.InitialJobState);
return manager;
});
services.AddScoped<FinalizeDocumentJob>();
services.AddScoped<ActionService>();
services.AddSingleton<TempFiles>();
services.AddScoped<PDFBurner>();
services.AddScoped<PDFMerger>();
services.AddScoped<ReportCreator>();
//TODO: Check lifetime of services. They might be singleton or scoped.
services.AddTransient<GdViewer>();
services.AddSingleton<LicenseManagerFactory>();
services.AddTransient<AnnotationManager>();
return services;
}
}