コード例 #1
0
        public async Task InvokeAsync(Expression <Action <TInterface> > exp)
        {
            IpcRequest  request  = GetRequest(exp, new MyInterceptor());
            IpcResponse response = await GetResponseAsync(request);

            if (response.Succeed)
            {
                return;
            }
            else
            {
                throw new InvalidOperationException(response.Failure);
            }
        }
コード例 #2
0
        public async Task <TResult> InvokeAsync <TResult>(Expression <Func <TInterface, TResult> > exp)
        {
            IpcRequest  request  = GetRequest(exp, new MyInterceptor <TResult>());
            IpcResponse response = await GetResponseAsync(request);

            if (response.Succeed)
            {
                if (_converter.TryConvert(response.Data, typeof(TResult), out object @return))
                {
                    return((TResult)@return);
                }
                else
                {
                    throw new InvalidOperationException($"Unable to convert returned value to '{typeof(TResult).Name}'.");
                }
            }
            else
            {
                throw new InvalidOperationException(response.Failure);
            }
        }
 public byte[] SerializeResponse(IpcResponse response)
 {
     return(Serialize(response));
 }