@@ -27,6 +27,16 @@ public HandlerInstance(string method, IJsonRpcHandler handler, Type handlerInter
2727 HandlerType = handlerInterface ;
2828 Params = @params ;
2929 Response = response ;
30+ HasReturnType = HandlerType . GetInterfaces ( ) . Any ( @interface =>
31+ @interface . IsGenericType &&
32+ typeof ( IRequestHandler < , > ) . IsAssignableFrom ( @interface . GetGenericTypeDefinition ( ) )
33+ ) ;
34+
35+ IsDelegatingHandler = @params ? . IsGenericType == true &&
36+ (
37+ typeof ( DelegatingRequest < > ) . IsAssignableFrom ( @params . GetGenericTypeDefinition ( ) ) ||
38+ typeof ( DelegatingNotification < > ) . IsAssignableFrom ( @params . GetGenericTypeDefinition ( ) )
39+ ) ;
3040 }
3141
3242 public IJsonRpcHandler Handler { get ; }
@@ -35,6 +45,8 @@ public HandlerInstance(string method, IJsonRpcHandler handler, Type handlerInter
3545 public string Method { get ; }
3646 public Type Params { get ; }
3747 public Type Response { get ; }
48+ public bool HasReturnType { get ; }
49+ public bool IsDelegatingHandler { get ; }
3850
3951 public void Dispose ( )
4052 {
@@ -61,7 +73,8 @@ private void Remove(IJsonRpcHandler handler)
6173 public IDisposable Add ( params IJsonRpcHandler [ ] handlers )
6274 {
6375 var cd = new CompositeDisposable ( ) ;
64- foreach ( var handler in handlers ) {
76+ foreach ( var handler in handlers )
77+ {
6578 cd . Add ( Add ( GetMethodName ( handler . GetType ( ) ) , handler ) ) ;
6679 }
6780 return cd ;
@@ -80,7 +93,9 @@ public IDisposable Add(string method, IJsonRpcHandler handler)
8093 var requestInterface = @params . GetInterfaces ( )
8194 . FirstOrDefault ( x => x . IsGenericType && x . GetGenericTypeDefinition ( ) == typeof ( IRequest < > ) ) ;
8295 if ( requestInterface != null )
96+ {
8397 response = requestInterface . GetGenericArguments ( ) [ 0 ] ;
98+ }
8499 }
85100
86101 var h = new HandlerInstance ( method , handler , @interface , @params , response , ( ) => Remove ( handler ) ) ;
0 commit comments