更新框架
This commit is contained in:
1 parent
ef50fa0620
commit
84b28f9672
72 files changed
+2222
-282
No files matched your search
@@ -0,0 +1,41 @@
|
||||
// 摘自 MediatR 14.2.0,许可声明与修改记录见 LICENSE.md 和 UPSTREAM.md。
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MAX.Notification;
|
||||
|
||||
/// <summary>
|
||||
/// 定义通知处理器。
|
||||
/// </summary>
|
||||
/// <typeparam name="TNotification">要处理的通知类型。</typeparam>
|
||||
public interface INotificationHandler<in TNotification>
|
||||
where TNotification : INotification
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理通知。
|
||||
/// </summary>
|
||||
/// <param name="notification">要处理的通知。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
Task Handle(TNotification notification, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步通知处理器的基类。
|
||||
/// </summary>
|
||||
/// <typeparam name="TNotification">通知类型。</typeparam>
|
||||
public abstract class NotificationHandler<TNotification> : INotificationHandler<TNotification>
|
||||
where TNotification : INotification
|
||||
{
|
||||
Task INotificationHandler<TNotification>.Handle(TNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
Handle(notification);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在派生类中重写此方法,实现同步通知处理逻辑。
|
||||
/// </summary>
|
||||
/// <param name="notification">要处理的通知。</param>
|
||||
protected abstract void Handle(TNotification notification);
|
||||
}
|
||||
Reference in new issue
Block a user