/// <summary> /// Performs a synchronous RPC operation on the given service. /// </summary> /// <typeparam name="TService">The service being used.</typeparam> /// <param name="client">The client to use to invoke the RPC call.</param> /// <param name="operation">An expression indicating the operation to perform.</param> public static void Invoke <TService>( this ProtoClient <TService> client, Expression <Action <TService> > operation) where TService : class { Action updateArgs; object[] args; MethodInfo method = ResolveMethod <TService>(operation, out updateArgs, out args); client.Invoke(method, args); if (updateArgs != null) { updateArgs(); } }
/// <summary> /// Performs an asynchronous RPC operation on the given service. /// </summary> /// <typeparam name="TService">The service being used.</typeparam> /// <param name="client">The client to use to invoke the RPC call.</param> /// <param name="operation">An expression indicating the operation to perform.</param> /// <param name="callback">A delegate that is invoked when the operation is complete. The /// callback is additionally given an `Action` that can be invoked to raise any exception /// associated with the call.</param> public static void InvokeAsync <TService>(this ProtoClient <TService> client, Expression <Action <TService> > operation, Action <Action> callback) where TService : class { Action updateArgs; object[] args; MethodInfo method = ResolveMethod <TService>(operation, out updateArgs, out args); client.InvokeAsync(method, result => { if (updateArgs != null) { updateArgs(); } callback(() => { result(); }); }); }
/// <summary> /// Performs a synchronous RPC operation on the given service. /// </summary> /// <typeparam name="TService">The service being used.</typeparam> /// <typeparam name="TResult">The result of the RPC call.</typeparam> /// <param name="client">The client to use to invoke the RPC call.</param> /// <param name="operation">An expression indicating the operation to perform.</param> /// <returns>The value of the RPC call.</returns> public static TResult Invoke <TService, TResult>( this ProtoClient <TService> client, Expression <Func <TService, TResult> > operation) where TService : class { Action updateArgs; object[] args; MethodInfo method = ResolveMethod <TService>(operation, out updateArgs, out args); TResult result = (TResult)client.Invoke(method, args); if (updateArgs != null) { updateArgs(); } return(result); }