using System.Configuration;
using System.Data;
using System.Windows;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
namespace ComplianceNFs.Monitor;
///
/// Interaction logic for App.xaml
///
public partial class App : Application
{
public static ServiceProvider? ServiceProvider { get; private set; }
private ILogger? _logger;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Setup DI and logging
ServiceProvider = LoggingBootstrapper.CreateServiceProvider();
_logger = ServiceProvider.GetRequiredService>();
_logger.LogInformation("App started");
this.DispatcherUnhandledException += (s, ex) =>
{
_logger?.LogError(ex.Exception, "Unhandled exception in WPF app");
};
// Optionally, resolve and show MainWindow with DI
var mainWindowLogger = ServiceProvider.GetRequiredService>();
var mainWindow = new MainWindow(mainWindowLogger);
mainWindow.Show();
}
}