Improve Publisher

This commit is contained in:
TheXamlGuy
2024-05-14 19:24:07 +01:00
parent adb5ffe57a
commit 4ba58a9863
22 changed files with 93 additions and 140 deletions
@@ -6,19 +6,18 @@ public class NotificationHandlerWrapper<TMessage>(INotificationHandler<TMessage>
private readonly IEnumerable<IPipelineBehaviour<TMessage>> pipelineBehaviours =
pipelineBehaviours.Reverse();
public async Task Handle(TMessage message,
CancellationToken cancellationToken)
public async Task Handle(TMessage message)
{
NotificationHandlerDelegate<TMessage> currentHandler = handler.Handle;
foreach (IPipelineBehaviour<TMessage> behaviour in pipelineBehaviours)
{
NotificationHandlerDelegate<TMessage> previousHandler = currentHandler;
currentHandler = async (args, token) =>
currentHandler = async (args) =>
{
await behaviour.Handle(args, previousHandler, token);
await behaviour.Handle(args, previousHandler);
};
}
await currentHandler(message, cancellationToken);
await currentHandler(message);
}
}