1- using System ;
1+ using System ;
2+ using System . Linq ;
23using System . Reflection ;
34using System . Threading ;
45using System . Threading . Tasks ;
@@ -23,7 +24,7 @@ public IDisposable Add(IJsonRpcHandler handler)
2324
2425 public async void RouteNotification ( Notification notification )
2526 {
26- var handler = _collection . Get ( notification . Method ) ;
27+ var handler = _collection . FirstOrDefault ( x => x . Method == notification . Method ) ;
2728
2829 Task result ;
2930 if ( handler . Params is null )
@@ -46,16 +47,14 @@ public Task<ErrorResponse> RouteRequest(Request request)
4647
4748 protected virtual async Task < ErrorResponse > RouteRequest ( Request request , CancellationToken token )
4849 {
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 )
5352 {
54- return new MethodNotFound ( request . Id ) ;
53+ return new MethodNotFound ( request . Id , request . Method ) ;
5554 }
5655
5756 Task result ;
58- if ( method . Params is null )
57+ if ( handler . Params is null )
5958 {
6059 result = ReflectionRequestHandlers . HandleRequest ( handler , token ) ;
6160 }
@@ -64,7 +63,7 @@ protected virtual async Task<ErrorResponse> RouteRequest(Request request, Cancel
6463 object @params ;
6564 try
6665 {
67- @params = request . Params . ToObject ( method . Params ) ;
66+ @params = request . Params . ToObject ( handler . Params ) ;
6867 }
6968 catch
7069 {
@@ -89,4 +88,4 @@ protected virtual async Task<ErrorResponse> RouteRequest(Request request, Cancel
8988 return new Client . Response ( request . Id , responseValue ) ;
9089 }
9190 }
92- }
91+ }
0 commit comments