模块化
This commit is contained in:
@@ -9,10 +9,11 @@ using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using LAEPS.PubEvent;
|
||||
using UIShare.PubEvent;
|
||||
using Notifications.Wpf.Core;
|
||||
using Logger;
|
||||
using Common;
|
||||
using ORM;
|
||||
|
||||
namespace LAEPS
|
||||
{
|
||||
@@ -33,7 +34,6 @@ namespace LAEPS
|
||||
}
|
||||
private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
//通常全局异常捕捉的都是致命信息
|
||||
LoggerHelper.Error(e.Exception.Message,e.Exception.StackTrace);
|
||||
}
|
||||
|
||||
@@ -50,20 +50,44 @@ namespace LAEPS
|
||||
}
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
var login=Container.Resolve<LoginView>();
|
||||
//初始化数据库
|
||||
DatabaseConfig.SetTenant(10001);
|
||||
DatabaseConfig.InitMySql("127.0.0.1",3306,"LAEPS","root","123456");
|
||||
DatabaseConfig.CreateDatabaseAndCheckConnection(createDatabase: true, checkConnection: true);
|
||||
SqlSugarContext.InitDatabase();
|
||||
//显示登录窗口
|
||||
var login=Container.Resolve<LoginModuleView>();
|
||||
var re=Container.Resolve<IRegionManager>();
|
||||
RegionManager.SetRegionManager(login, re);
|
||||
RegionManager.SetRegionManager(Application.Current.MainWindow, re);
|
||||
login.Show();
|
||||
}
|
||||
protected override void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
//注册视图
|
||||
containerRegistry.RegisterForNavigation<MainView>("MainView");
|
||||
containerRegistry.RegisterForNavigation<SettingView>("SettingView");
|
||||
containerRegistry.RegisterForNavigation<UpdateInfoView>("UpdateInfoView");
|
||||
//注册弹窗
|
||||
containerRegistry.RegisterDialog<MessageBoxView, MessageBoxViewModel>("MessageBox");
|
||||
// 注册通知管理器
|
||||
INotificationManager NotificationManager = new NotificationManager();
|
||||
containerRegistry.RegisterInstance<INotificationManager>(NotificationManager);
|
||||
}
|
||||
//指定模块加载方式(需要手动将模块生成的dll放入Modules文件夹中)
|
||||
protected override IModuleCatalog CreateModuleCatalog()
|
||||
{
|
||||
//指定模块加载方式为从文件夹中以反射发现并加载module(推荐用法)
|
||||
return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
|
||||
}
|
||||
//手动模块加载方式
|
||||
//protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
|
||||
//{
|
||||
// Type moduleAType = typeof(LoginModule.LoginModule);
|
||||
// moduleCatalog.AddModule(new ModuleInfo()
|
||||
// {
|
||||
// ModuleName = moduleAType.Name,
|
||||
// ModuleType = moduleAType.AssemblyQualifiedName,
|
||||
// InitializationMode = InitializationMode.OnDemand
|
||||
// });
|
||||
|
||||
// base.ConfigureModuleCatalog(moduleCatalog);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user