Exemple #1
0
        HttpControllerDescriptor IHttpControllerSelector.SelectController(HttpRequestMessage request)
        {
            HttpControllerDescriptor controllerDescriptor = null;

            _traceWriter.TraceBeginEnd(
                request,
                TraceCategories.ControllersCategory,
                TraceLevel.Info,
                _innerSelector.GetType().Name,
                SelectControllerMethodName,
                beginTrace: (tr) =>
            {
                tr.Message = Error.Format(
                    SRResources.TraceRouteMessage,
                    FormattingUtilities.RouteToString(request.GetRouteData()));
            },
                execute: () =>
            {
                controllerDescriptor = _innerSelector.SelectController(request);
            },
                endTrace: (tr) =>
            {
                tr.Message = controllerDescriptor == null
                                        ? SRResources.TraceNoneObjectMessage
                                        : controllerDescriptor.ControllerName;
            },
                errorTrace: null);

            if (controllerDescriptor != null && !(controllerDescriptor is HttpControllerDescriptorTracer))
            {
                return(new HttpControllerDescriptorTracer(controllerDescriptor.Configuration, controllerDescriptor.ControllerName, controllerDescriptor.ControllerType, controllerDescriptor, _traceWriter));
            }

            return(controllerDescriptor);
        }