Exemplo n.º 1
0
        /// <exception cref="IpcSerializationException">If unable to serialize request</exception>
        /// <exception cref="IpcCommunicationException">If communication is broken</exception>
        /// <exception cref="IpcFaultException">If error occurred in server</exception>
        public async Task InvokeAsync(Expression <Func <TInterface, Task> > exp,
                                      CancellationToken cancellationToken = default)
        {
            IpcRequest  request  = GetRequest(exp, new MyInterceptor <Task>());
            IpcResponse response = await GetResponseAsync(request, cancellationToken).ConfigureAwait(false);

            if (!response.Succeed())
            {
                throw response.CreateFaultException();
            }
        }
Exemplo n.º 2
0
        /// <exception cref="IpcSerializationException">If unable to serialize request</exception>
        /// <exception cref="IpcCommunicationException">If communication is broken</exception>
        /// <exception cref="IpcFaultException">If error occurred in server</exception>
        public async Task InvokeAsync(Expression <Action <TInterface> > exp,
                                      CancellationToken cancellationToken = default)
        {
            IpcRequest  request  = GetRequest(exp, DispatchProxy.Create <TInterface, IpcProxy>());
            IpcResponse response = await GetResponseAsync(request, cancellationToken).ConfigureAwait(false);

            if (!response.Succeed())
            {
                throw response.CreateFaultException();
            }
        }
Exemplo n.º 3
0
        /// <exception cref="IpcSerializationException">If unable to serialize request</exception>
        /// <exception cref="IpcCommunicationException">If communication is broken</exception>
        /// <exception cref="IpcFaultException">If error occurred in server</exception>
        public async Task <TResult> InvokeAsync <TResult>(Expression <Func <TInterface, TResult> > exp,
                                                          CancellationToken cancellationToken = default)
        {
            IpcRequest  request  = GetRequest(exp, new MyInterceptor <TResult>());
            IpcResponse response = await GetResponseAsync(request, cancellationToken).ConfigureAwait(false);

            if (!response.Succeed())
            {
                throw response.CreateFaultException();
            }

            if (!_options.ValueConverter.TryConvert(response.Data, typeof(TResult), out object @return))
            {
                throw new IpcSerializationException($"Unable to convert returned value to '{typeof(TResult).Name}'.");
            }

            return((TResult)@return);
        }