1
- using System ;
1
+ using System ;
2
+ using System . Linq ;
2
3
using System . Reflection ;
3
4
using System . Threading ;
4
5
using System . Threading . Tasks ;
@@ -23,7 +24,7 @@ public IDisposable Add(IJsonRpcHandler handler)
23
24
24
25
public async void RouteNotification ( Notification notification )
25
26
{
26
- var handler = _collection . Get ( notification . Method ) ;
27
+ var handler = _collection . FirstOrDefault ( x => x . Method == notification . Method ) ;
27
28
28
29
Task result ;
29
30
if ( handler . Params is null )
@@ -46,16 +47,14 @@ public Task<ErrorResponse> RouteRequest(Request request)
46
47
47
48
protected virtual async Task < ErrorResponse > RouteRequest ( Request request , CancellationToken token )
48
49
{
49
- var handler = _collection . Get ( request . Method ) ;
50
-
51
- var method = _collection . Get ( request . Method ) ;
52
- if ( method is null )
50
+ var handler = _collection . FirstOrDefault ( x => x . Method == request . Method ) ;
51
+ if ( request . Method is null )
53
52
{
54
- return new MethodNotFound ( request . Id ) ;
53
+ return new MethodNotFound ( request . Id , request . Method ) ;
55
54
}
56
55
57
56
Task result ;
58
- if ( method . Params is null )
57
+ if ( handler . Params is null )
59
58
{
60
59
result = ReflectionRequestHandlers . HandleRequest ( handler , token ) ;
61
60
}
@@ -64,7 +63,7 @@ protected virtual async Task<ErrorResponse> RouteRequest(Request request, Cancel
64
63
object @params ;
65
64
try
66
65
{
67
- @params = request . Params . ToObject ( method . Params ) ;
66
+ @params = request . Params . ToObject ( handler . Params ) ;
68
67
}
69
68
catch
70
69
{
@@ -89,4 +88,4 @@ protected virtual async Task<ErrorResponse> RouteRequest(Request request, Cancel
89
88
return new Client . Response ( request . Id , responseValue ) ;
90
89
}
91
90
}
92
- }
91
+ }
0 commit comments