Ejemplo n.º 1
0
        /// <summary>
        /// Implements a modification or extension of the client across an endpoint.
        /// </summary>
        /// <param name="endpoint">The endpoint that is to be customized.</param>
        /// <param name="clientRuntime">The client runtime to be customized.</param>
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            WcfMessageInspector inspector = new WcfMessageInspector(endpoint, this._clientCredentials);

            inspector.IgnoreMessageInspect  = this.IgnoreMessageInspect;
            inspector.IgnoreMessageValidate = this.IgnoreMessageValidate;

            inspector.SendingRequest += (s, e) => this.RaiseEvent(this.SendingRequest, endpoint, e);
            inspector.ReceivingReply += (s, e) => this.RaiseEvent(this.ReceivingReply, endpoint, e);
            inspector.ErrorOccurred  += (s, e) => this.RaiseEvent(this.ErrorOccurred, e);

            clientRuntime.MessageInspectors.Add(inspector);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Implements a modification or extension of the service across an endpoint.
        /// </summary>
        /// <param name="endpoint">The endpoint that exposes the contract.</param>
        /// <param name="endpointDispatcher">The endpoint dispatcher to be modified or extended.</param>
        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            WcfMessageInspector inspector = new WcfMessageInspector(endpoint, this._serviceHostBase);

            inspector.IgnoreMessageInspect  = this.IgnoreMessageInspect;
            inspector.IgnoreMessageValidate = this.IgnoreMessageValidate;

            inspector.ReceivingRequest += (s, e) => this.RaiseEvent(this.ReceivingRequest, endpoint, e);
            inspector.SendingReply     += (s, e) => this.RaiseEvent(this.SendingReply, endpoint, e);
            inspector.ErrorOccurred    += (s, e) => this.RaiseEvent(this.ErrorOccurred, e);

            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(inspector);

            WcfErrorHandler errorHandler = new WcfErrorHandler();

            errorHandler.ErrorOccurred += (s, e) => this.RaiseEvent(this.ErrorOccurred, e);

            endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(errorHandler);
        }