-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathDebugAdapterRequestRouter.cs
30 lines (24 loc) · 1.36 KB
/
DebugAdapterRequestRouter.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
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.JsonRpc.Server;
namespace OmniSharp.Extensions.DebugAdapter.Shared
{
internal class DebugAdapterRequestRouter : RequestRouterBase<IHandlerDescriptor>
{
private readonly DebugAdapterHandlerCollection _collection;
public DebugAdapterRequestRouter(
DebugAdapterHandlerCollection collection, ISerializer serializer, IServiceScopeFactory serviceScopeFactory, ILogger<DebugAdapterRequestRouter> logger,
IActivityTracingStrategy? activityTracingStrategy = null
)
: base(serializer, serviceScopeFactory, logger, activityTracingStrategy) =>
_collection = collection;
public IDisposable Add(IJsonRpcHandler handler) => _collection.Add(handler);
private IRequestDescriptor<IHandlerDescriptor> FindDescriptor(IMethodWithParams instance) =>
new RequestDescriptor<IHandlerDescriptor>(_collection.Where(x => x.Method == instance.Method));
public override IRequestDescriptor<IHandlerDescriptor> GetDescriptors(Notification notification) => FindDescriptor(notification);
public override IRequestDescriptor<IHandlerDescriptor> GetDescriptors(Request request) => FindDescriptor(request);
}
}