Пример #1
0
        private async Task ProfermAsync(IInvocation invocation)
        {
            var targetType = invocation.TargetType.IsInterface ?
                             invocation.TargetType : invocation.TargetType.GetInterfaces()[0];
            var request = new MethodRpcRequest
            {
                TargetType   = targetType,
                TargetMethod = invocation.MethodInvocationTarget,
                Params       = invocation.Arguments
            };
            var response = await _rpcClient.InvokeMethodAsync(request);

            if (response.Status == -1)
            {
                if (response.Exception != null)
                {
                    throw response.Exception;
                }
                else
                {
                    throw new System.Exception("RPC调用异常");
                }
            }
            invocation.ReturnValue = response.ReturnData;
        }