Exemple #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);

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

                    if (returnValue is string)
                    {
                        return((string)returnValue);
                    }

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

                    throw;
                }
            }
        }
Exemple #2
0
        internal ViewComponent CreateViewComponent(TemplateParserContext context)
        {
            ViewComponent controller = (ViewComponent)Activator.CreateInstance(_classType);

            controller.Initialize(this, context);

            return(controller);
        }