void IEngineViewSupport.RenderSection(string sectionName, TextWriter output, ViewBase view, RenderContext renderContext) { if(sectionName == null) { renderContext.BodyContent.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(renderContext.BodyContent); CopyStream(reader, output); } }
void IEngineViewSupport.RenderPartial(string sharedViewName, TextWriter output, ViewBase view) { FindAndExecuteSharedView(SharedViewRole.Partial, sharedViewName, output, null, view, null, null); }
private ViewBase FindAndExecuteSharedView(SharedViewRole role, string sharedViewName, TextWriter output, ControllerBase controller, ViewBase parentView, Stream bodyContent, Dictionary<string,Action> sections) { var viewKey = "/#" + sharedViewName; CachedView viewData; viewData = GetCachedView(viewKey); if (viewData != null) { viewData = CheckCachedSharedViewValidity(role, sharedViewName, viewData); } if (viewData == null) { viewData = LoadSharedView(role, sharedViewName, viewKey, viewData); SaveViewInCache(viewKey, viewData); } var view = (ViewBase)Activator.CreateInstance(viewData.ViewType); InitializeView(controller, parentView, view, output, new RenderContext { BodyContent = bodyContent,Sections = sections }); view.Execute(); return view; }
private void InitializeView(ControllerBase controller, ViewBase parentView, ViewBase view, TextWriter output, RenderContext renderContext) { if (controller != null) { view.ViewBag = controller.ViewBag; } else { view.ViewBag = parentView.ViewBag; } view.InitializeView(output, this, renderContext); }
private void ExecuteViewWithFilter(string controllerName, string actionName, Dictionary<string, object> parameters, ControllerBase controller, ViewBase view) { _pipelineFilter.BeforeView(controller, controllerName, actionName, parameters); try { view.Execute(); } catch (Exception ex) { _pipelineFilter.ViewError(controller, controllerName, actionName, parameters, ex); throw; } _pipelineFilter.AfterView(controller, controllerName, actionName, parameters); }