Pull Request 33523 suggestions
Pull Request 33520 suggestions Injected AppSettings instead of using GetEnvironmentVariable at Services level When debugging only app.Services.GetRequiredService<IPCRBService>(); Get ready to use VSCode IDE Align .editorconfig files
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net.Mail;
|
||||
|
||||
using FabApprovalWorkerService.Clients;
|
||||
using FabApprovalWorkerService.Models;
|
||||
using FabApprovalWorkerService.Services;
|
||||
using FabApprovalWorkerService.Workers;
|
||||
|
||||
@ -6,8 +10,6 @@ using NLog.Extensions.Logging;
|
||||
|
||||
using Quartz;
|
||||
|
||||
using System.Net.Mail;
|
||||
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
||||
|
||||
builder.Logging.ClearProviders();
|
||||
@ -16,10 +18,20 @@ builder.Logging.AddNLog();
|
||||
|
||||
builder.Services.AddHttpClient();
|
||||
|
||||
if (Debugger.IsAttached) {
|
||||
string? asmHtrTrainingGroupName = Environment.GetEnvironmentVariable("AsmHtrTrainingGroupName");
|
||||
if (string.IsNullOrEmpty(asmHtrTrainingGroupName)) {
|
||||
AppSettings.SetEnvironmentVariables(builder);
|
||||
}
|
||||
}
|
||||
|
||||
AppSettings appSettings = AppSettings.LoadEnvironmentVariables();
|
||||
builder.Services.AddSingleton(_ => appSettings);
|
||||
|
||||
builder.Services.AddScoped<IDbConnectionService, DbConnectionService>();
|
||||
builder.Services.AddScoped<IMonInClient, MonInClient>();
|
||||
builder.Services.AddScoped<IDalService, DalService>();
|
||||
builder.Services.AddScoped<SmtpClient>((serviceProvider) => {
|
||||
builder.Services.AddScoped((serviceProvider) => {
|
||||
return new SmtpClient("mailrelay-external.infineon.com");
|
||||
});
|
||||
builder.Services.AddScoped<ISmtpClientWrapper, SmtpClientWrapper>();
|
||||
@ -126,4 +138,7 @@ builder.Services.AddHostedService<WindowsService>();
|
||||
|
||||
IHost app = builder.Build();
|
||||
|
||||
app.Run();
|
||||
if (Debugger.IsAttached)
|
||||
app.Services.GetRequiredService<IApprovalService>();
|
||||
|
||||
app.Run();
|
Reference in New Issue
Block a user