-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathNoopResponseRouter.cs
More file actions
67 lines (56 loc) · 1.83 KB
/
Copy pathNoopResponseRouter.cs
File metadata and controls
67 lines (56 loc) · 1.83 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Newtonsoft.Json.Linq;
namespace OmniSharp.Extensions.JsonRpc
{
/// <summary>
/// Used top ensure noop behaviors don't throw if they consume a router
/// </summary>
internal class NoopResponseRouter : IResponseRouter
{
private NoopResponseRouter()
{
}
public static NoopResponseRouter Instance { get; } = new NoopResponseRouter();
public void SendNotification(string method)
{
}
public void SendNotification<T>(string method, T @params)
{
}
public void SendNotification(IRequest<Unit> request)
{
}
public IResponseRouterReturns SendRequest<T>(string method, T @params)
{
return new Impl();
}
public IResponseRouterReturns SendRequest(string method)
{
return new Impl();
}
public Task<TResponse> SendRequest<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken)
{
return Task.FromResult<TResponse>(default!);
}
bool IResponseRouter.TryGetRequest(object id, [NotNullWhen(true)] out string? method, [NotNullWhen(true)] out TaskCompletionSource<JToken>? pendingTask)
{
method = default!;
pendingTask = default!;
return false;
}
private class Impl : IResponseRouterReturns
{
public Task<TResponse> Returning<TResponse>(CancellationToken cancellationToken)
{
return Task.FromResult<TResponse>(default!);
}
public Task ReturningVoid(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
}
}