Exemple #1
0
        private string Execute(TRequest request, string nextRequestHandlerId, ref RequestHandlerResult result)
        {
            string lastRequestHandlerId;

            try
            {
                this._requestHandler.Context.Request = request;

                result = RequestHandlerOrchestrator
                         .ExecuteHandler(request, (RequestHandler <TContext, TRequest>) this._requestHandler, nextRequestHandlerId);
            }
            catch (PipelinePolicyException px)
            {
                result = px.Result;
            }
            catch (Exception ex)
            {
                if (Log.Logger != null)
                {
                    using (LogContext.PushProperty("RequestKey", this._requestKey))
                    {
                        Log.Logger.Error(ex, string.Concat("Error - ", this._requestHandler.Context.CurrentRequestHandleId));
                    }
                }
            }
            finally
            {
                lastRequestHandlerId = this._requestHandler.Context.CurrentRequestHandleId;
                result = ExecuteFinallyHandler(request) ?? result;
            }

            return(lastRequestHandlerId);
        }
Exemple #2
0
        public RequestHandlerResult Execute(TRequest request)
        {
            if (this._validator != null)
            {
                var validateResult = this._validator.Validate(request);

                if (validateResult.IsValid == false)
                {
                    var errors = (validateResult.Errors.Select(p =>
                                                               new ErrorResult(null, p.ErrorMessage, p.PropertyName))).ToList();
                    return(new RequestHandlerResult(errors, 400));
                }
            }

            if (this._requestHandler == null)
            {
                throw new ArgumentNullException("No started handlers");
            }

            this._requestHandler.Context.Request = request;

            var result = RequestHandlerOrchestrator.ExecuteHandler(request, this._requestHandler);

            result = ExecuteFinallyHandler(request) ?? result;

            return(result);
        }
        private string Execute(TRequest request, string nextRequestHandlerId, ref RequestHandlerResult result)
        {
            string lastRequestHandlerId;
            try
            {
                this._requestHandler.Context.Request = request;

                result = RequestHandlerOrchestrator
                    .ExecuteHandler(request, (RequestHandler<TContext, TRequest>)this._requestHandler, nextRequestHandlerId);
            }
            catch(PipelinePolicyException px)
            {
                result = px.Result;
            }
            catch (Exception ex)
            {
                //faz nada
            }
            finally
            {
                lastRequestHandlerId = this._requestHandler.Context.CurrentRequestHandleId;
                result = ExecuteFinallyHandler(request) ?? result;
            }

            return lastRequestHandlerId;
        }
Exemple #4
0
        public RequestHandlerResult Next(string requestHandlerId)
        {
            if (this.NextRequestHandler != null)
            {
                this.Context.Response = RequestHandlerOrchestrator.ExecuteHandler((RequestHandler <TContext>) this.NextRequestHandler, requestHandlerId);
            }

            return(this.Context.Response);
        }
Exemple #5
0
        public RequestHandlerResult Next(TRequest request)
        {
            if (this.NextRequestHandler != null)
            {
                this.Context.Response = RequestHandlerOrchestrator.ExecuteHandler(request, this.NextRequestHandler);
            }

            return(this.Context.Response);
        }