-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediatR.cs
41 lines (26 loc) · 962 Bytes
/
MediatR.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using MediatR;
namespace Veronica.Sandbox {
public class MediatR : INotificationHandler<AccidentNotification> {
private readonly IMediator _mediator;
public MediatR(IMediator _mediator) {
this._mediator = _mediator;
}
public async Task Process() {
await Task.Delay(100);
Console.ReadLine();
var accident = new AccidentNotification("Oslo", DateTime.Now);
await _mediator.Publish(accident);
}
public Task Handle(AccidentNotification notification, CancellationToken cancellationToken) {
return Task.CompletedTask;
}
}
public class AccidentNotification : INotification {
public string Location { get; }
public DateTime Time { get; }
public AccidentNotification(string location, DateTime time) {
Location = location;
Time = time;
}
}
}