49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using Prism.Events;
|
|
using Prism.Ioc;
|
|
using Prism.Mvvm;
|
|
|
|
namespace SopHelper.Core.Prism;
|
|
|
|
/// <summary>
|
|
/// 模型Base
|
|
/// </summary>
|
|
public class ModelBase : BindableBase
|
|
{
|
|
/// <summary>
|
|
/// 事件聚合器
|
|
/// </summary>
|
|
protected readonly IEventAggregator _eventAggregator;
|
|
|
|
/// <summary>
|
|
/// DI 容器
|
|
/// </summary>
|
|
protected readonly IContainerExtension _container;
|
|
|
|
/// <summary>
|
|
/// 模型Base
|
|
/// </summary>
|
|
public ModelBase(IContainerExtension container, IEventAggregator ea)
|
|
{
|
|
_container = container;
|
|
_eventAggregator = ea;
|
|
|
|
_eventAggregator.GetEvent<MessageEvent>().Subscribe(OnMessage, ThreadOption.PublisherThread, true);
|
|
|
|
AppDomain.CurrentDomain.ProcessExit += OnExit;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 收到消息(子类覆写做本模块的落库/统计)
|
|
/// </summary>
|
|
protected virtual void OnMessage(Message message)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进程退出(子类覆写做释放)
|
|
/// </summary>
|
|
protected virtual void OnExit(object? sender, EventArgs e)
|
|
{
|
|
}
|
|
}
|