Files
EnvelopeGenerator/EnvelopeGenerator.ServiceHost/Extensions/DependencyInjection.cs
TekH 2172ce8203 Register AnnotationManager as transient service
Updated DI comment for clarity on service lifetimes and added AnnotationManager as a transient service to the dependency injection container.
2026-02-25 17:03:59 +01:00

38 lines
1.4 KiB
C#

using DigitalData.Modules.Database;
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(nameof(WorkerOptions)));
services.AddSingleton<FinalizeDocumentJob>();
services.AddScoped<ActionService>();
services.AddSingleton<TempFiles>();
services.AddScoped<PDFBurner>();
services.AddScoped<PDFMerger>();
services.AddScoped<ReportModel>();
services.AddSingleton<State>();
services.AddScoped<MSSQLServer>();
//TODO: Check lifetime of services. They might be singleton or scoped.
services.AddTransient<GdViewer>();
// Add LicenseManager
services.AddTransient(provider =>
{
var options = provider.GetRequiredService<IOptions<WorkerOptions>>().Value;
var licenseManager = new LicenseManager();
licenseManager.RegisterKEY(options.GdPictureLicenseKey);
return licenseManager;
});
services.AddTransient<AnnotationManager>();
return services;
}
}