/// <summary>
        /// Creates the specified request context.
        /// </summary>
        /// <param name="requestContext">The request context.</param>
        /// <param name="controllerType">Type of the controller.</param>
        /// <returns></returns>
        public override IController Create(RequestContext requestContext, Type controllerType)
        {
            if (controllerType == null)
            {
                return(null);
            }

            Type activatorType = ControllerActivatorRegistry.Matching(controllerType);

            IControllerActivator activator = activatorType != null ?
                                             (IControllerActivator)Container.GetServices(activatorType) :
                                             null;

            Controller controller = activator != null?
                                    activator.Create(requestContext, controllerType) as Controller:
                                    (GetControllerInstance(controllerType) ?? Activator.CreateInstance(controllerType)) as Controller;

            if (controller != null)
            {
                Type actionInvokerType;

                if (ActionInvokerRegistry.IsRegistered(controllerType))
                {
                    actionInvokerType = ActionInvokerRegistry.Matching(controllerType);
                }
                else
                {
                    actionInvokerType = controller is IAsyncController ?
                                        KnownTypes.AsyncActionInvokerType :
                                        KnownTypes.SyncActionInvokerType;
                }

                IActionInvoker actionInvoker = Container.GetService(actionInvokerType) as IActionInvoker;

                if (actionInvoker != null)
                {
                    controller.ActionInvoker = actionInvoker;
                }
            }

            return(controller);
        }
 protected override void Register(ActionInvokerRegistry registry)
 {
     registry.RegisterSyncActionInvoker<HomeController, TestActionInvoker>();
 }
 protected abstract void Register(ActionInvokerRegistry registry);
Exemplo n.º 4
0
 protected override void Register(ActionInvokerRegistry registry)
 {
     registry.RegisterSyncActionInvoker <HomeController, TestActionInvoker>();
 }