版本260406
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OrpaonVision.SiteApp.DependencyInjection;
|
||||
using System.Windows;
|
||||
|
||||
namespace OrpaonVision.SiteApp
|
||||
@@ -9,6 +10,37 @@ namespace OrpaonVision.SiteApp
|
||||
/// </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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user