Fixed Warnings
This commit is contained in:
@@ -32,13 +32,11 @@ public partial class App : Application
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private IHost? _host;
|
||||
private CancellationTokenSource? _cancellationTokenSource;
|
||||
|
||||
#endregion
|
||||
|
||||
private IHost? Host {get; set;}
|
||||
private CancellationTokenSource? CancellationTokenSource { get; set;}
|
||||
|
||||
|
||||
#region Methods
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
@@ -51,7 +49,7 @@ public partial class App : Application
|
||||
// catch all unhandled errors
|
||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder();
|
||||
HostApplicationBuilder builder = Microsoft.Extensions.Hosting.Host.CreateApplicationBuilder();
|
||||
|
||||
builder
|
||||
// Register the Random Logging Service
|
||||
@@ -77,7 +75,7 @@ public partial class App : Application
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(builder.Configuration)
|
||||
.WriteTo.DataStoreLoggerSink( dataStoreProvider: () => _host!.Services.TryGetService<ILogDataStore>()!,formatProvider: CultureInfo.InvariantCulture)
|
||||
.WriteTo.DataStoreLoggerSink( dataStoreProvider: () => Host!.Services.TryGetService<ILogDataStore>()!,formatProvider: CultureInfo.InvariantCulture)
|
||||
.CreateLogger();
|
||||
|
||||
cfg.ClearProviders().AddSerilog(Log.Logger);
|
||||
@@ -90,19 +88,19 @@ public partial class App : Application
|
||||
DataContext = service.GetRequiredService<MainViewModel>()
|
||||
});
|
||||
|
||||
_host = builder.Build();
|
||||
_cancellationTokenSource = new();
|
||||
Host = builder.Build();
|
||||
CancellationTokenSource = new();
|
||||
|
||||
try
|
||||
{
|
||||
LogStartingMode();
|
||||
|
||||
// set and show
|
||||
desktop.MainWindow = _host.Services.GetRequiredService<MainWindow>();
|
||||
desktop.MainWindow = Host.Services.GetRequiredService<MainWindow>();
|
||||
desktop.ShutdownRequested += OnShutdownRequested;
|
||||
|
||||
// startup background services
|
||||
_ = _host.StartAsync(_cancellationTokenSource.Token);
|
||||
_ = Host.StartAsync(CancellationTokenSource.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -162,7 +160,7 @@ public partial class App : Application
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// initialize a logger & EventId
|
||||
ILogger<App> logger = _host!.Services.GetRequiredService<ILogger<App>>();
|
||||
ILogger<App> logger = Host!.Services.GetRequiredService<ILogger<App>>();
|
||||
EventId eventId = new(id: 0, name: Assembly.GetEntryAssembly()!.GetName().Name);
|
||||
|
||||
// log a test pattern for each log level
|
||||
@@ -175,7 +173,7 @@ public partial class App : Application
|
||||
private void CleanUp()
|
||||
{
|
||||
// tell the background services that we are shutting down
|
||||
_ = _host?.StopAsync(_cancellationTokenSource?.Token ?? CancellationToken.None);
|
||||
_ = Host?.StopAsync(CancellationTokenSource?.Token ?? CancellationToken.None);
|
||||
|
||||
// flush logs
|
||||
Log.CloseAndFlush();
|
||||
|
||||
Reference in New Issue
Block a user