automapper框架优化
This commit is contained in:
@@ -20,6 +20,9 @@ using UIShare;
|
||||
using System;
|
||||
using DeviceCommand.Device;
|
||||
using DeviceCommand.Base;
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using ADP.Profiles;
|
||||
|
||||
namespace ADP
|
||||
{
|
||||
@@ -68,6 +71,22 @@ namespace ADP
|
||||
RegionManager.SetRegionManager(Application.Current.MainWindow, re);
|
||||
login.Show();
|
||||
}
|
||||
protected override void RegisterRequiredTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
base.RegisterRequiredTypes(containerRegistry);
|
||||
//注册全局变量
|
||||
containerRegistry.RegisterScoped<SystemConfig>();
|
||||
containerRegistry.RegisterScoped<StepRunning>();
|
||||
containerRegistry.RegisterScoped<ScopedContext>();
|
||||
containerRegistry.RegisterScoped<DeviceManager>();
|
||||
containerRegistry.RegisterSingleton<GlobalInfo>();
|
||||
//注册AutoMapper
|
||||
var config = new MapperConfiguration(
|
||||
cfg => cfg.AddProfile<AutoMapperProfile>(),
|
||||
NullLoggerFactory.Instance
|
||||
);
|
||||
containerRegistry.RegisterSingleton<IMapper>(() => config.CreateMapper());
|
||||
}
|
||||
protected override void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
//注册弹窗
|
||||
@@ -75,12 +94,8 @@ namespace ADP
|
||||
// 注册通知管理器
|
||||
INotificationManager NotificationManager = new NotificationManager();
|
||||
containerRegistry.RegisterInstance<INotificationManager>(NotificationManager);
|
||||
//注册全局变量
|
||||
containerRegistry.RegisterScoped<SystemConfig>();
|
||||
containerRegistry.RegisterScoped<StepRunning>();
|
||||
containerRegistry.RegisterScoped<ScopedContext>();
|
||||
containerRegistry.RegisterScoped<DeviceManager>();
|
||||
containerRegistry.RegisterSingleton<GlobalInfo>();
|
||||
// 注册仓储
|
||||
containerRegistry.RegisterScoped(typeof(SqlSugarRepository<>));
|
||||
}
|
||||
//指定模块加载方式(需要手动将模块生成的dll放入Modules文件夹中)
|
||||
protected override IModuleCatalog CreateModuleCatalog()
|
||||
|
||||
Reference in New Issue
Block a user