예제 #1
0
        IHttpController IHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
        {
            IHttpController controller = null;

            _traceWriter.TraceBeginEnd(
                request,
                TraceCategories.ControllersCategory,
                TraceLevel.Info,
                _innerActivator.GetType().Name,
                CreateMethodName,
                beginTrace: null,
                execute: () =>
            {
                controller = _innerActivator.Create(request, controllerDescriptor, controllerType);
            },
                endTrace: (tr) =>
            {
                tr.Message = controller == null ? SRResources.TraceNoneObjectMessage : controller.GetType().FullName;
            },
                errorTrace: null);

            if (controller != null && !(controller is HttpControllerTracer))
            {
                controller = new HttpControllerTracer(request, controller, _traceWriter);
            }

            return(controller);
        }
예제 #2
0
            public IHttpController Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
            {
                if (controllerType == typeof(SchedulerController) && PrefixMatches(request))
                {
                    return(new SchedulerController(_scheduler));
                }

                if (controllerType == typeof(SchedulerController) && _nestedActivator.GetType() != typeof(SimpleControllerActicator))
                {
                    // We can't activate CommandsController
                    throw new InvalidOperationException("Couldn't activate SchedulerController instance");
                }

                return(_nestedActivator.Create(request, controllerDescriptor, controllerType));
            }