@@ -125,17 +125,6 @@ public static void RpcSetException(JsonRpcException exception)
125125 throw new InvalidOperationException ( "This method is only valid when used within the context of a method marked as a JsonRpcMethod, and that method must of been invoked by the JsonRpc Handler." ) ;
126126 }
127127
128- private void RemoveRpcException ( )
129- {
130- if ( Task . CurrentId != null )
131- {
132- var id = Task . CurrentId . Value ;
133- RpcExceptions [ id ] = null ;
134- JsonRpcException va ;
135- RpcExceptions . TryRemove ( id , out va ) ;
136- }
137- }
138-
139128 private AustinHarris . JsonRpc . PreProcessHandler externalPreProcessingHandler ;
140129 private AustinHarris . JsonRpc . PostProcessHandler externalPostProcessingHandler ;
141130 private Func < JsonRequest , JsonRpcException , JsonRpcException > externalErrorHandler ;
@@ -151,9 +140,42 @@ private void RemoveRpcException()
151140
152141 #region Public Methods
153142
154- public void UnRegister ( string key )
143+ /// <summary>
144+ /// Allows you to register all the functions on a Pojo Type that have been attributed as [JsonRpcMethod] to the specified sessionId
145+ /// </summary>
146+ /// <param name="sessionID">The session to register against</param>
147+ /// <param name="instance">The instance containing JsonRpcMethods to register</param>
148+ public static void RegisterInstance ( string sessionID , object instance )
149+ {
150+ ServiceBinder . BindService ( sessionID , instance ) ;
151+ }
152+
153+ /// <summary>
154+ /// Allows you to register any function, lambda, etc even when not attributed with JsonRpcMethod.
155+ /// Requires you to specify all types and defaults
156+ /// </summary>
157+ /// <param name="methodName">The method name that will map to the registered function</param>
158+ /// <param name="parameterNameTypeMapping">The parameter names and types that will be positionally bound to the function</param>
159+ /// <param name="parameterNameDefaultValueMapping">Optional default values for parameters</param>
160+ /// <param name="implementation">A reference to the Function</param>
161+ public void RegisterFuction ( string methodName , Dictionary < string , Type > parameterNameTypeMapping , Dictionary < string , object > parameterNameDefaultValueMapping , Delegate implementation )
162+ {
163+ MetaData . AddService ( methodName , parameterNameTypeMapping , parameterNameDefaultValueMapping , implementation ) ;
164+ }
165+
166+ public void UnRegisterFunction ( string methodName )
167+ {
168+ MetaData . Services . Remove ( methodName ) ;
169+ }
170+
171+ public void SetPreProcessHandler ( AustinHarris . JsonRpc . PreProcessHandler handler )
172+ {
173+ externalPreProcessingHandler = handler ;
174+ }
175+
176+ public void SetPostProcessHandler ( AustinHarris . JsonRpc . PostProcessHandler handler )
155177 {
156- MetaData . Services . Remove ( key ) ;
178+ externalPostProcessingHandler = handler ;
157179 }
158180
159181 /// <summary>
@@ -370,7 +392,7 @@ public JsonResponse Handle(JsonRequest Rpc, Object RpcContext = null, Action<Jso
370392 RemoveRpcContext ( ) ;
371393 }
372394 }
373-
395+ #endregion
374396 /// <summary>
375397 /// Method returns the actual callback set to this thread in Handle() method.
376398 /// If callback is not set, then empty callback is returned.
@@ -428,7 +450,18 @@ internal void SetParseErrorHandler(Func<string, JsonRpcException, JsonRpcExcepti
428450 parseErrorHandler = handler ;
429451 }
430452
431- #endregion
453+ private void RemoveRpcException ( )
454+ {
455+ if ( Task . CurrentId != null )
456+ {
457+ var id = Task . CurrentId . Value ;
458+ RpcExceptions [ id ] = null ;
459+ JsonRpcException va ;
460+ RpcExceptions . TryRemove ( id , out va ) ;
461+ }
462+ }
463+
464+
432465 private object CleanUpParameter ( object p , SMDAdditionalParameters metaData )
433466 {
434467 var bob = p as JValue ;
@@ -522,15 +555,6 @@ private JsonResponse PostProcess(Action<JsonResponse> callback, JsonRequest requ
522555 return response ;
523556 }
524557
525- public void SetPreProcessHandler ( AustinHarris . JsonRpc . PreProcessHandler handler )
526- {
527- externalPreProcessingHandler = handler ;
528- }
529-
530- public void SetPostProcessHandler ( AustinHarris . JsonRpc . PostProcessHandler handler )
531- {
532- externalPostProcessingHandler = handler ;
533- }
534558 }
535559
536560}
0 commit comments