public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { var viewResult = _themeAwareViewEngine.FindPartialView(controllerContext, viewName, useCache, true); if (viewResult.View == null) { return viewResult; } if (!ThemeFilter.IsApplied(controllerContext.RequestContext)) { return viewResult; } var layoutView = new LayoutView((viewContext, writer, viewDataContainer) => { Logger.Information("Rendering layout view"); var childContentWriter = new HtmlStringWriter(); var childContentViewContext = new ViewContext( viewContext, viewContext.View, viewContext.ViewData, viewContext.TempData, childContentWriter); viewResult.View.Render(childContentViewContext, childContentWriter); _workContext.Layout.Metadata.ChildContent = childContentWriter; var display = _displayHelperFactory.CreateHelper(viewContext, viewDataContainer); IHtmlString result = display(_workContext.Layout); writer.Write(result.ToHtmlString()); Logger.Information("Done rendering layout view"); }, (context, view) => viewResult.ViewEngine.ReleaseView(context, viewResult.View)); return new ViewEngineResult(layoutView, this); }
private IHtmlString PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, object serviceInstance) { var output = new HtmlStringWriter(); var arguments = methodInfo.GetParameters() .Select(parameter => BindParameter(displayContext, parameter, output)); var returnValue = methodInfo.Invoke(serviceInstance, arguments.ToArray()); if (methodInfo.ReturnType != typeof(void)) { output.Write(CoerceHtmlString(returnValue)); } return output; }