Ejemplo n.º 1
0
        CommandHandlerDescriptor ICommandHandlerSelector.SelectHandler(CommandHandlerRequest request)
        {
            CommandHandlerDescriptor handlerDescriptor = null;

            this.traceWriter.TraceBeginEnd(
                request,
                TraceCategories.HandlersCategory,
                TraceLevel.Info,
                this.innerSelector.GetType().Name,
                SelectActionMethodName,
                beginTrace: null,
                execute: () => handlerDescriptor = this.innerSelector.SelectHandler(request),
                endTrace: tr =>
            {
                tr.Message = Error.Format(
                    Resources.TraceHandlerSelectedMessage,
                    FormattingUtilities.HandlerDescriptorToString(handlerDescriptor));
            },
                errorTrace: null);

            // Intercept returned HttpActionDescriptor with a tracing version
            if (handlerDescriptor != null && !(handlerDescriptor is CommandHandlerDescriptorTracer))
            {
                return(new CommandHandlerDescriptorTracer(handlerDescriptor, this.traceWriter));
            }

            return(handlerDescriptor);
        }
        /// <summary>
        /// The on command executing.
        /// </summary>
        /// <param name="handlerContext">
        /// The handler context.
        /// </param>
        public override void OnCommandExecuting(CommandHandlerContext handlerContext)
        {
            if (handlerContext == null)
            {
                throw Error.ArgumentNull("handlerContext");
            }

            this.traceWriter.TraceBeginEnd(
                handlerContext.Request,
                TraceCategories.FiltersCategory,
                TraceLevel.Info,
                this.innerFilter.GetType().Name,
                OnCommandExecutingMethodName,
                beginTrace: tr =>
            {
                tr.Message = Error.Format(Resources.TraceActionFilterMessage, FormattingUtilities.HandlerDescriptorToString(handlerContext.Descriptor));
            },
                execute: () => this.innerFilter.OnCommandExecuting(handlerContext),
                endTrace: null,
                errorTrace: null);
        }