dev
Last change
on this file since ad058b3 was ad058b3, checked in by Стојков Марко <mst@…>, 3 years ago |
Hangfire is supported
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[ad058b3] | 1 | using FinkiChattery.Common.Mediator.Contracs;
|
---|
[e6a6d9a] | 2 | using FinkiChattery.Common.Mediator.Interfaces;
|
---|
[ad058b3] | 3 | using MediatR;
|
---|
| 4 | using System.ComponentModel;
|
---|
[e6a6d9a] | 5 | using System.Threading;
|
---|
| 6 | using System.Threading.Tasks;
|
---|
| 7 |
|
---|
| 8 | namespace FinkiChattery.Common.Mediator
|
---|
| 9 | {
|
---|
| 10 | public class MediatorService : IMediatorService
|
---|
| 11 | {
|
---|
| 12 | private readonly IMediator mediator;
|
---|
| 13 |
|
---|
| 14 | public MediatorService(IMediator mediator)
|
---|
| 15 | {
|
---|
| 16 | this.mediator = mediator;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | public async Task<TResponse> SendAsync<TResponse>(ICommand<TResponse> request, CancellationToken cancellationToken)
|
---|
| 20 | {
|
---|
| 21 | return await mediator.Send(request, cancellationToken);
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | public async Task<TResponse> SendAsync<TResponse>(ICommand<TResponse> request)
|
---|
| 25 | {
|
---|
| 26 | return await mediator.Send(request);
|
---|
| 27 | }
|
---|
[ad058b3] | 28 |
|
---|
| 29 | public async Task PublishAsync<TNotification>(TNotification notification) where TNotification : IEvent
|
---|
| 30 | {
|
---|
| 31 | await mediator.Publish(notification, default);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | [DisplayName("{0}")]
|
---|
| 35 | public async Task PublishAsync<TNotification>(string jobName, TNotification notification) where TNotification : IEvent
|
---|
| 36 | {
|
---|
| 37 | await mediator.Publish(notification, default);
|
---|
| 38 | }
|
---|
[e6a6d9a] | 39 | }
|
---|
| 40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.