Exemplo n.º 1
0
        /// <summary>
        /// Invokes ThrowOrIgnore of handlers in the pipeline ony by one.
        /// </summary>
        /// <param name="context">The context associated with the current call.</param>
        /// <param name="detail">The exception details.</param>
        protected override void ThrowOrIgnoreCore(ClientCallInterceptorContext context, ClientFaultDetail detail)
        {
            for (var i = 0; i < _pipeline.Count; i++)
            {
                var handler = _pipeline[i];

                handler.ThrowOrIgnore(context, detail);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// If current call is cancelled invokes OnOperationCancelled, otherwise invokes ThrowOrIgnoreCore.
        /// </summary>
        /// <param name="context">The context associated with the current call.</param>
        /// <param name="detail">The exception details.</param>
        public virtual void ThrowOrIgnore(ClientCallInterceptorContext context, ClientFaultDetail detail)
        {
            // the request is already aborted, no extra details are available from server
            if (IsOperationCancelled(context, detail.OriginalError))
            {
                OnOperationCancelled(context, detail.OriginalError);
            }

            ThrowOrIgnoreCore(context, detail);
        }
Exemplo n.º 3
0
        public void BeforeEachTest()
        {
            _sut = new Mock <ClientErrorHandlerBase> {
                CallBase = true
            };

            _tokenSource = new CancellationTokenSource();

            var method = new Mock <IMethod>(MockBehavior.Strict);

            _callContext = new ClientCallInterceptorContext(new CallOptions(new Metadata(), cancellationToken: _tokenSource.Token), null, method.Object);

            _faultDetail = new ClientFaultDetail(new RpcException(Status.DefaultCancelled), new object());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Handle the exception that was raised by <see cref="CallInvoker"/>.
 /// </summary>
 /// <param name="context">The context associated with the current call.</param>
 /// <param name="detail">The exception details.</param>
 protected abstract void ThrowOrIgnoreCore(ClientCallInterceptorContext context, ClientFaultDetail detail);
Exemplo n.º 5
0
 /// <summary>
 /// Enables custom action when call is cancelled.
 /// Call is already aborted by a client, no external detail is available.
 /// </summary>
 /// <param name="context">The context associated with the current call.</param>
 /// <param name="error">The original <see cref="RpcException"/> raised by <see cref="CallInvoker"/>.</param>
 protected virtual void OnOperationCancelled(ClientCallInterceptorContext context, RpcException error)
 {
     throw new OperationCanceledException(null, error, context.CallOptions.CancellationToken);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Return true is the current call was cancelled.
 /// </summary>
 /// <param name="context">The context associated with the current call.</param>
 /// <param name="error">The original <see cref="RpcException"/> raised by <see cref="CallInvoker"/>.</param>
 /// <returns>True if current call was cancelled, otherwise false.</returns>
 public static bool IsOperationCancelled(ClientCallInterceptorContext context, RpcException error)
 {
     return(context.CallOptions.CancellationToken.IsCancellationRequested);
 }