refactor(Finalizer.Program): simplify EnvelopeGenerator service registration using AddEnvelopeGenerator extension
- Replaced manual service setup with AddEnvelopeGenerator fluent configuration - Added EnvelopeGenerator.DependencyInjection namespace - Integrated distributed SQL Server cache for EG services - Improved DI structure and reduced obsolete warnings
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using EnvelopeGenerator.Application;
|
||||
using EnvelopeGenerator.DependencyInjection;
|
||||
using EnvelopeGenerator.Finalizer;
|
||||
using EnvelopeGenerator.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -27,25 +27,28 @@ try
|
||||
var connStr = config.GetConnectionString(cnnStrName)
|
||||
?? throw new InvalidOperationException($"Connection string '{cnnStrName}' is missing in the application configuration.");
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
builder.Services.AddEGInfrastructureServices(
|
||||
opt =>
|
||||
builder.Services.AddEnvelopeGenerator(egOptions => egOptions
|
||||
.AddLocalization()
|
||||
.AddDistributedSqlServerCache(options =>
|
||||
{
|
||||
options.ConnectionString = connStr;
|
||||
options.SchemaName = "dbo";
|
||||
options.TableName = "TBDD_CACHE";
|
||||
})
|
||||
.AddInfrastructure(opt =>
|
||||
{
|
||||
opt.AddDbTriggerParams(config);
|
||||
opt.AddDbContext((provider, options) =>
|
||||
{
|
||||
var logger = provider.GetRequiredService<ILogger<EGDbContext>>();
|
||||
options.UseSqlServer(connStr)
|
||||
.LogTo(log => logger.LogInformation("{log}", log), Microsoft.Extensions.Logging.LogLevel.Trace)
|
||||
.LogTo(log => logger.LogInformation("{log}", log), LogLevel.Trace)
|
||||
.EnableSensitiveDataLogging()
|
||||
.EnableDetailedErrors();
|
||||
});
|
||||
});
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
builder.Services.AddEnvelopeGeneratorServices(config);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
})
|
||||
.AddServices(config)
|
||||
);
|
||||
#endregion Add DB Context, EG Inf. and Services
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
Reference in New Issue
Block a user