清理引用,将NavigatorServices更改为使用Message来实现导航的切换
This commit is contained in:
118
App.xaml.cs
118
App.xaml.cs
@@ -1,8 +1,5 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog;
|
||||
using NLog.Extensions.Logging;
|
||||
@@ -12,72 +9,73 @@ using PMSWPF.Data.Repositories;
|
||||
using PMSWPF.Services;
|
||||
using PMSWPF.ViewModels;
|
||||
using PMSWPF.Views;
|
||||
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||
|
||||
namespace PMSWPF
|
||||
namespace PMSWPF;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
public App()
|
||||
{
|
||||
public new static App Current => (App)Application.Current;
|
||||
public IServiceProvider Services { get; }
|
||||
var container = new ServiceCollection();
|
||||
|
||||
public App()
|
||||
var nlog = LogManager.Setup().LoadConfigurationFromFile("Config/nlog.config").GetCurrentClassLogger();
|
||||
|
||||
container.AddLogging(loggingBuilder =>
|
||||
{
|
||||
var container = new ServiceCollection();
|
||||
|
||||
var nlog = LogManager.Setup().LoadConfigurationFromFile("Config/nlog.config").GetCurrentClassLogger();
|
||||
|
||||
container.AddLogging(loggingBuilder =>
|
||||
{
|
||||
loggingBuilder.ClearProviders();
|
||||
loggingBuilder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
||||
loggingBuilder.AddNLog();
|
||||
});
|
||||
loggingBuilder.ClearProviders();
|
||||
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
|
||||
loggingBuilder.AddNLog();
|
||||
});
|
||||
|
||||
|
||||
container.AddSingleton<NavgatorServices>();
|
||||
container.AddSingleton<DevicesRepositories>();
|
||||
container.AddSingleton<IDeviceDialogService, DeviceDialogService>();
|
||||
container.AddSingleton<GrowlNotificationService>();
|
||||
container.AddSingleton<MainViewModel>();
|
||||
container.AddSingleton<HomeViewModel>();
|
||||
container.AddSingleton<DevicesViewModel>();
|
||||
container.AddSingleton<DataTransformViewModel>();
|
||||
container.AddSingleton<SettingViewModel>();
|
||||
container.AddSingleton<SettingView>();
|
||||
container.AddSingleton<MainView>();
|
||||
container.AddSingleton<HomeView>();
|
||||
container.AddSingleton<DevicesView>();
|
||||
container.AddSingleton<DataTransformViewModel>();
|
||||
container.AddSingleton<NavgatorServices>();
|
||||
container.AddSingleton<DevicesRepositories>();
|
||||
container.AddSingleton<IDeviceDialogService, DeviceDialogService>();
|
||||
container.AddSingleton<GrowlNotificationService>();
|
||||
container.AddSingleton<MainViewModel>();
|
||||
container.AddSingleton<HomeViewModel>();
|
||||
container.AddSingleton<DevicesViewModel>();
|
||||
container.AddSingleton<DataTransformViewModel>();
|
||||
container.AddSingleton<SettingViewModel>();
|
||||
container.AddSingleton<SettingView>();
|
||||
container.AddSingleton<MainView>();
|
||||
container.AddSingleton<HomeView>();
|
||||
container.AddSingleton<DevicesView>();
|
||||
container.AddSingleton<DataTransformViewModel>();
|
||||
container.AddSingleton<VariableTableViewModel>();
|
||||
container.AddSingleton<VariableTableView>();
|
||||
Services = container.BuildServiceProvider();
|
||||
// 启动服务
|
||||
Services.GetRequiredService<GrowlNotificationService>();
|
||||
}
|
||||
|
||||
Services = container.BuildServiceProvider();
|
||||
// 启动服务
|
||||
Services.GetRequiredService<GrowlNotificationService>();
|
||||
}
|
||||
public new static App Current => (App)Application.Current;
|
||||
public IServiceProvider Services { get; }
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
InitDB();
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
InitDB();
|
||||
|
||||
MainWindow = Services.GetRequiredService<MainView>();
|
||||
MainWindow.Show();
|
||||
}
|
||||
MainWindow = Services.GetRequiredService<MainView>();
|
||||
MainWindow.Show();
|
||||
}
|
||||
|
||||
private void InitDB()
|
||||
{
|
||||
var _db = DbContext.GetInstance();
|
||||
_db.DbMaintenance.CreateDatabase();
|
||||
_db.CodeFirst.InitTables<DbNlog>();
|
||||
_db.CodeFirst.InitTables<DbNlog>();
|
||||
_db.CodeFirst.InitTables<DbDevice>();
|
||||
_db.CodeFirst.InitTables<DbVariableTable>();
|
||||
_db.CodeFirst.InitTables<DbDataVariable>();
|
||||
_db.CodeFirst.InitTables<DbS7DataVariable>();
|
||||
_db.CodeFirst.InitTables<DbUser>();
|
||||
_db.CodeFirst.InitTables<DbMqtt>();
|
||||
}
|
||||
private void InitDB()
|
||||
{
|
||||
var _db = DbContext.GetInstance();
|
||||
_db.DbMaintenance.CreateDatabase();
|
||||
_db.CodeFirst.InitTables<DbNlog>();
|
||||
_db.CodeFirst.InitTables<DbNlog>();
|
||||
_db.CodeFirst.InitTables<DbDevice>();
|
||||
_db.CodeFirst.InitTables<DbVariableTable>();
|
||||
_db.CodeFirst.InitTables<DbDataVariable>();
|
||||
_db.CodeFirst.InitTables<DbS7DataVariable>();
|
||||
_db.CodeFirst.InitTables<DbUser>();
|
||||
_db.CodeFirst.InitTables<DbMqtt>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user