47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using OrpaonVision.SiteApp.DependencyInjection;
|
|
using System.Windows;
|
|
|
|
namespace OrpaonVision.SiteApp
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
private ServiceProvider? _serviceProvider;
|
|
|
|
/// <inheritdoc />
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
base.OnStartup(e);
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
.SetBasePath(AppContext.BaseDirectory)
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true)
|
|
.Build();
|
|
|
|
var services = new ServiceCollection();
|
|
services.AddSiteAppServices(configuration);
|
|
services.AddSingleton<MainWindow>();
|
|
services.AddSingleton<OptimizedMainWindow>();
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
|
|
|
// 启动优化窗口
|
|
var optimizedWindow = _serviceProvider.GetRequiredService<OptimizedMainWindow>();
|
|
optimizedWindow.Show();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void OnExit(ExitEventArgs e)
|
|
{
|
|
_serviceProvider?.Dispose();
|
|
base.OnExit(e);
|
|
}
|
|
}
|
|
|
|
}
|