Exemplo n.º 1
0
        internal static string RunViewComponent(ControllerAction controllerAction, TemplateParserContext context)
        {
            ControllerClass controllerClass = controllerAction.ControllerClass;

            if (!controllerClass.IsActionMethod(controllerAction.ActionMethod))
            {
                return(null);
            }

            using (ViewComponent component = controllerClass.CreateViewComponent(context))
            {
                try
                {
                    controllerClass.SetupController(component, context);

                    string returnValue = controllerClass.Run(component, "Run", context) as string;

                    if (returnValue != null)
                    {
                        return(returnValue);
                    }

                    return(TemplateUtil.ExtractBody(component.View.Render()));
                }
                catch
                {
                    component.SkipTearDown = true;

                    throw;
                }
            }
        }
Exemplo n.º 2
0
        internal ViewComponent CreateViewComponent(TemplateParserContext context)
        {
            ViewComponent controller = (ViewComponent)Activator.CreateInstance(_classType);

            controller.Initialize(this, context);

            return(controller);
        }