refactor: add conditional PDFBurner and GdPicture service registration
This commit is contained in:
parent
d2e8f1fc5e
commit
86c0a65540
@ -24,9 +24,10 @@ public static class DependencyInjection
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services"></param>
|
/// <param name="services"></param>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
|
/// <param name="usePdfBurner"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Obsolete("Use MediatR")]
|
[Obsolete("Use MediatR")]
|
||||||
public static IServiceCollection AddEnvelopeGeneratorServices(this IServiceCollection services, IConfiguration config)
|
public static IServiceCollection AddEnvelopeGeneratorServices(this IServiceCollection services, IConfiguration config, bool usePdfBurner = false)
|
||||||
{
|
{
|
||||||
//Inject CRUD Service and repositoriesad
|
//Inject CRUD Service and repositoriesad
|
||||||
services.TryAddScoped<IConfigService, ConfigService>();
|
services.TryAddScoped<IConfigService, ConfigService>();
|
||||||
@ -50,25 +51,31 @@ public static class DependencyInjection
|
|||||||
services.Configure<MailParams>(config.GetSection(nameof(MailParams)));
|
services.Configure<MailParams>(config.GetSection(nameof(MailParams)));
|
||||||
services.Configure<AuthenticatorParams>(config.GetSection(nameof(AuthenticatorParams)));
|
services.Configure<AuthenticatorParams>(config.GetSection(nameof(AuthenticatorParams)));
|
||||||
services.Configure<TotpSmsParams>(config.GetSection(nameof(TotpSmsParams)));
|
services.Configure<TotpSmsParams>(config.GetSection(nameof(TotpSmsParams)));
|
||||||
services.Configure<PDFBurnerParams>(config.GetSection(nameof(PDFBurnerParams)));
|
|
||||||
services.AddOptions<GdPictureParams>()
|
if (usePdfBurner)
|
||||||
.Configure((GdPictureParams opt, IServiceProvider provider) =>
|
|
||||||
{
|
{
|
||||||
opt.License = config["GdPictureLicenseKey"]
|
services.Configure<PDFBurnerParams>(config.GetSection(nameof(PDFBurnerParams)));
|
||||||
?? provider.GetRequiredService<IMediator>().ReadThirdPartyModuleLicenseAsync("GDPICTURE").GetAwaiter().GetResult()
|
services.AddOptions<GdPictureParams>()
|
||||||
?? throw new InvalidOperationException($"License record not found for key: {"GDPICTURE"}");
|
.Configure((GdPictureParams opt, IServiceProvider provider) =>
|
||||||
});
|
{
|
||||||
services.AddSingleton(provider => {
|
opt.License = config["GdPictureLicenseKey"]
|
||||||
var license = provider.GetRequiredService<IOptions<GdPictureParams>>().Value.License;
|
?? provider.GetRequiredService<IMediator>().ReadThirdPartyModuleLicenseAsync("GDPICTURE").GetAwaiter().GetResult()
|
||||||
var licenseManager = new LicenseManager();
|
?? throw new InvalidOperationException($"License record not found for key: {"GDPICTURE"}");
|
||||||
licenseManager.RegisterKEY(license);
|
});
|
||||||
return licenseManager;
|
services.AddSingleton(provider =>
|
||||||
});
|
{
|
||||||
services.AddTransient(provider => {
|
var license = provider.GetRequiredService<IOptions<GdPictureParams>>().Value.License;
|
||||||
// Ensure LicenseManager is resolved so that its constructor is called
|
var licenseManager = new LicenseManager();
|
||||||
_ = provider.GetRequiredService<LicenseManager>();
|
licenseManager.RegisterKEY(license);
|
||||||
return new AnnotationManager();
|
return licenseManager;
|
||||||
});
|
});
|
||||||
|
services.AddTransient(provider =>
|
||||||
|
{
|
||||||
|
// Ensure LicenseManager is resolved so that its constructor is called
|
||||||
|
_ = provider.GetRequiredService<LicenseManager>();
|
||||||
|
return new AnnotationManager();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
services.AddHttpClientService<GtxMessagingParams>(config.GetSection(nameof(GtxMessagingParams)));
|
services.AddHttpClientService<GtxMessagingParams>(config.GetSection(nameof(GtxMessagingParams)));
|
||||||
services.TryAddSingleton<ISmsSender, GTXSmsSender>();
|
services.TryAddSingleton<ISmsSender, GTXSmsSender>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user