|
7 | 7 |
|
8 | 8 | namespace DispatchR; |
9 | 9 |
|
10 | | -public interface IMediator |
11 | | -{ |
12 | | - TResponse Send<TRequest, TResponse>(IRequest<TRequest, TResponse> request, |
13 | | - CancellationToken cancellationToken) where TRequest : class, IRequest; |
14 | | - |
15 | | - IAsyncEnumerable<TResponse> CreateStream<TRequest, TResponse>(IStreamRequest<TRequest, TResponse> request, |
16 | | - CancellationToken cancellationToken) where TRequest : class, IStreamRequest; |
17 | | - |
18 | | - ValueTask Publish<TNotification>(TNotification request, CancellationToken cancellationToken) |
19 | | - where TNotification : INotification; |
20 | | - |
21 | | - /// <summary> |
22 | | - /// This method is not recommended for performance-critical scenarios. |
23 | | - /// Use it only if it is strictly necessary, as its performance is lower compared |
24 | | - /// to similar methods in terms of both memory usage and CPU consumption. |
25 | | - /// </summary> |
26 | | - /// <param name="request"> |
27 | | - /// An object that implements INotification |
28 | | - /// </param> |
29 | | - /// <param name="cancellationToken"></param> |
30 | | - /// <returns></returns> |
31 | | - [Obsolete(message: "This method has performance issues. Use only if strictly necessary", |
32 | | - error: false, |
33 | | - DiagnosticId = Constants.DiagnosticPerformanceIssue)] |
34 | | - ValueTask Publish(object request, CancellationToken cancellationToken); |
35 | | -} |
36 | | - |
37 | 10 | public sealed class Mediator(IServiceProvider serviceProvider) : IMediator |
38 | 11 | { |
39 | 12 | public TResponse Send<TRequest, TResponse>(IRequest<TRequest, TResponse> request, |
@@ -73,6 +46,19 @@ public async ValueTask Publish<TNotification>(TNotification request, Cancellatio |
73 | 46 | } |
74 | 47 | } |
75 | 48 |
|
| 49 | + /// <summary> |
| 50 | + /// This method is not recommended for performance-critical scenarios. |
| 51 | + /// Use it only if it is strictly necessary, as its performance is lower compared |
| 52 | + /// to similar methods in terms of both memory usage and CPU consumption. |
| 53 | + /// </summary> |
| 54 | + /// <param name="request"> |
| 55 | + /// An object that implements INotification |
| 56 | + /// </param> |
| 57 | + /// <param name="cancellationToken"></param> |
| 58 | + /// <returns></returns> |
| 59 | + [Obsolete(message: "This method has performance issues. Use only if strictly necessary", |
| 60 | + error: false, |
| 61 | + DiagnosticId = Constants.DiagnosticPerformanceIssue)] |
76 | 62 | public async ValueTask Publish(object request, CancellationToken cancellationToken) |
77 | 63 | { |
78 | 64 | ArgumentNullException.ThrowIfNull(request); |
|
0 commit comments