| | | 1 | | using Elsa.Mediator.Contracts; |
| | | 2 | | using Elsa.Mediator.Options; |
| | | 3 | | |
| | | 4 | | // ReSharper disable once CheckNamespace |
| | | 5 | | namespace Elsa.Extensions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Provides a set of extension methods for <see cref="IMediator"/>. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class MediatorExtensions |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Sends a notification using the default notification strategy configured via <see cref="MediatorOptions"/>. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="mediator">The mediator.</param> |
| | | 16 | | /// <param name="notification">The notification to send.</param> |
| | | 17 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | 18 | | public static async Task SendAsync(this IMediator mediator, INotification notification, CancellationToken cancellati |
| | | 19 | | { |
| | 0 | 20 | | await mediator.SendAsync(notification, default, cancellationToken); |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Sends a notification using the default notification strategy configured via <see cref="MediatorOptions"/>. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <param name="publisher">The publisher.</param> |
| | | 27 | | /// <param name="notification">The notification to send.</param> |
| | | 28 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | 29 | | public static async Task SendAsync(this INotificationSender publisher, INotification notification, CancellationToken |
| | | 30 | | { |
| | 0 | 31 | | await publisher.SendAsync(notification, default, cancellationToken); |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Sends a command using the default command strategy configured via <see cref="MediatorOptions"/>. |
| | | 36 | | /// </summary> |
| | | 37 | | /// <param name="mediator">The mediator.</param> |
| | | 38 | | /// <param name="command">The command to send.</param> |
| | | 39 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | 40 | | public static async Task SendAsync(this IMediator mediator, ICommand command, CancellationToken cancellationToken = |
| | | 41 | | { |
| | 0 | 42 | | await mediator.SendAsync(command, null, cancellationToken); |
| | 0 | 43 | | } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Sends a command using the default command strategy configured via <see cref="MediatorOptions"/>. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <param name="commandSender">The command sender.</param> |
| | | 49 | | /// <param name="command">The command to send.</param> |
| | | 50 | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | 51 | | public static async Task SendAsync(this ICommandSender commandSender, ICommand command, CancellationToken cancellati |
| | | 52 | | { |
| | 0 | 53 | | await commandSender.SendAsync(command, null, cancellationToken); |
| | 0 | 54 | | } |
| | | 55 | | } |