|
9 | 9 |
|
10 | 10 | namespace OmniSharp.Extensions.JsonRpc
|
11 | 11 | {
|
12 |
| - public class ResponseRouter : IResponseRouter |
| 12 | + internal class ResponseRouter : IResponseRouter |
13 | 13 | {
|
14 |
| - internal readonly IOutputHandler OutputHandler; |
| 14 | + internal readonly Lazy<IOutputHandler> OutputHandler; |
15 | 15 | internal readonly ISerializer Serializer;
|
16 | 16 | private readonly IHandlerTypeDescriptorProvider<IHandlerTypeDescriptor> _handlerTypeDescriptorProvider;
|
17 | 17 |
|
18 | 18 | internal readonly ConcurrentDictionary<long, (string method, TaskCompletionSource<JToken> pendingTask)> Requests =
|
19 | 19 | new ConcurrentDictionary<long, (string method, TaskCompletionSource<JToken> pendingTask)>();
|
20 | 20 |
|
21 |
| - public ResponseRouter(IOutputHandler outputHandler, ISerializer serializer, IHandlerTypeDescriptorProvider<IHandlerTypeDescriptor> handlerTypeDescriptorProvider) |
| 21 | + public ResponseRouter(Lazy<IOutputHandler> outputHandler, ISerializer serializer, IHandlerTypeDescriptorProvider<IHandlerTypeDescriptor> handlerTypeDescriptorProvider) |
22 | 22 | {
|
23 | 23 | OutputHandler = outputHandler;
|
24 | 24 | Serializer = serializer;
|
25 | 25 | _handlerTypeDescriptorProvider = handlerTypeDescriptorProvider;
|
26 | 26 | }
|
27 | 27 |
|
28 | 28 | public void SendNotification(string method) =>
|
29 |
| - OutputHandler.Send( |
| 29 | + OutputHandler.Value.Send( |
30 | 30 | new OutgoingNotification {
|
31 | 31 | Method = method
|
32 | 32 | }
|
33 | 33 | );
|
34 | 34 |
|
35 | 35 | public void SendNotification<T>(string method, T @params) =>
|
36 |
| - OutputHandler.Send( |
| 36 | + OutputHandler.Value.Send( |
37 | 37 | new OutgoingNotification {
|
38 | 38 | Method = method,
|
39 | 39 | Params = @params
|
@@ -81,7 +81,7 @@ public async Task<TResponse> Returning<TResponse>(CancellationToken cancellation
|
81 | 81 |
|
82 | 82 | cancellationToken.ThrowIfCancellationRequested();
|
83 | 83 |
|
84 |
| - _router.OutputHandler.Send( |
| 84 | + _router.OutputHandler.Value.Send( |
85 | 85 | new OutgoingRequest {
|
86 | 86 | Method = _method,
|
87 | 87 | Params = _params,
|
|
0 commit comments