public void Merge(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                return;
            }

            if (other.AvailableSerializers != null)
            {
                AvailableSerializers = other.AvailableSerializers;
            }
            if (other.ExceptionSerializer != null)
            {
                ExceptionSerializer = other.ExceptionSerializer;
            }
            if (other.Options != null)
            {
                Options = other.Options;
            }
            if (other.DefaultSerializer != null)
            {
                DefaultSerializer = other.DefaultSerializer;
            }
            if (other.ErrorHandler != null)
            {
                ErrorHandler = other.ErrorHandler;
            }
        }
Ejemplo n.º 2
0
        public void Merge(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                return;
            }

            if (other.Serializer != null)
            {
                Serializer = other.Serializer;
            }
            if (other.ExceptionWrapper != null)
            {
                ExceptionWrapper = other.ExceptionWrapper;
            }
            if (other.Options != null)
            {
                Options = other.Options;
            }
            if (other.Serializer != null)
            {
                Serializer = other.Serializer;
            }
            if (other.ErrorHandler != null)
            {
                ErrorHandler = other.ErrorHandler;
            }
        }
Ejemplo n.º 3
0
        public void Merge(ServerRuntimeConfiguration other)
        {
            if (other == null)
            {
                return;
            }

            if (other.AvailableSerializers != null)
            {
                AvailableSerializers = other.AvailableSerializers;
            }
            if (other.ExceptionWrapper != null)
            {
                ExceptionWrapper = other.ExceptionWrapper;
            }
            if (other.Options != null)
            {
                Options = other.Options;
            }
            if (other.DefaultSerializer != null)
            {
                DefaultSerializer = other.DefaultSerializer;
            }
            if (other.ErrorHandler != null)
            {
                ErrorHandler = other.ErrorHandler;
            }
        }
 public void Reset()
 {
     DefaultSerializer    = null;
     AvailableSerializers = null;
     ExceptionSerializer  = null;
     Options      = null;
     ErrorHandler = null;
 }
Ejemplo n.º 5
0
        public ServerCallErrorInterceptor(
            IServerErrorHandler errorHandler,
            IMarshallerFactory marshallerFactory)
        {
            errorHandler.AssertNotNull(nameof(errorHandler));
            marshallerFactory.AssertNotNull(nameof(marshallerFactory));

            _errorHandler      = errorHandler;
            _marshallerFactory = marshallerFactory;
        }
Ejemplo n.º 6
0
        public void BeforeEachTest()
        {
            _clientMetadata = new List <Metadata.Entry>();

            var clientErrorHandler = new Mock <IClientErrorHandler>(MockBehavior.Strict);

            clientErrorHandler
            .Setup(h => h.ThrowOrIgnore(It.IsAny <ClientCallInterceptorContext>(), It.IsAny <ClientFaultDetail>()))
            .Callback <ClientCallInterceptorContext, ClientFaultDetail>((_, detail) =>
            {
                _clientMetadata.AddRange(detail
                                         .OriginalError
                                         .Trailers
                                         .Where(i => "GlobalErrorHandler".Equals(i.Key, StringComparison.OrdinalIgnoreCase) || "LocalErrorHandler".Equals(i.Key, StringComparison.OrdinalIgnoreCase)));
            });

            _host = new KestrelHost()
                    .ConfigureClientFactory(options => options.ErrorHandler = clientErrorHandler.Object);

            var globalErrorHandler = new Mock <IServerErrorHandler>(MockBehavior.Strict);

            globalErrorHandler
            .Setup(h => h.ProvideFaultOrIgnore(It.IsAny <ServerCallInterceptorContext>(), It.IsNotNull <Exception>()))
            .Returns <ServerCallInterceptorContext, Exception>((context, ex) =>
            {
                ex.ShouldBeOfType <ApplicationException>();
                context.ServerCallContext.ResponseTrailers.Add(new Metadata.Entry("GlobalErrorHandler", "dummy"));
                return(null);
            });
            _globalErrorHandler = globalErrorHandler.Object;

            var localErrorHandler = new Mock <IServerErrorHandler>(MockBehavior.Strict);

            localErrorHandler
            .Setup(h => h.ProvideFaultOrIgnore(It.IsAny <ServerCallInterceptorContext>(), It.IsNotNull <Exception>()))
            .Returns <ServerCallInterceptorContext, Exception>((context, ex) =>
            {
                ex.ShouldBeOfType <ApplicationException>();
                context.ServerCallContext.ResponseTrailers.Add(new Metadata.Entry("LocalErrorHandler", "dummy"));
                return(null);
            });
            _localErrorHandler = localErrorHandler.Object;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Adds the given error handler to the end of this list.
        /// </summary>
        /// <param name="errorHandler">The <see cref="IServerErrorHandler"/>.</param>
        public void Add(IServerErrorHandler errorHandler)
        {
            errorHandler.AssertNotNull(nameof(errorHandler));

            _pipeline.Add(errorHandler);
        }
Ejemplo n.º 8
0
 /// <summary>
 ///     Constructs a <see cref="ServerSelector"/>.
 /// </summary>
 /// <param name="errorHandler">A handler for server selection errors.</param>
 /// <param name="prompter">A handler for server selection prompts.</param>
 public ServerSelector(IServerErrorHandler errorHandler, IServerPrompter prompter)
 {
     _errorHandler = errorHandler;
     _prompter     = prompter;
 }