예제 #1
0
        string IMasterView.Render(IContentView view)
        {
            HttpContext.Trace.Write("JumonyMasterView", "Begin Render");
            OnPreRender();
            RenderAdapters.Add(view.CreateContentAdapter(this));
            var content = Document.Render(RenderAdapters.ToArray());

            OnPostRender();
            HttpContext.Trace.Write("JumonyMasterView", "End Render");

            return(content);
        }
예제 #2
0
        protected override string RenderContent()
        {
            var writer = new StringWriter();


            foreach (var node in Container.Nodes())
            {
                node.Render(writer, RenderAdapters.ToArray());
            }


            return(writer.ToString());
        }
예제 #3
0
        /// <summary>
        /// 渲染视图
        /// </summary>
        /// <param name="viewContext">视图上下文</param>
        /// <param name="writer">文本编写器</param>
        public virtual void Render(ViewContext viewContext, TextWriter writer)
        {
            ViewContext = viewContext;

            //获取视图筛选器
            Filters = ViewData[ViewFiltersDataKey] as IEnumerable <IViewFilter> ?? Enumerable.Empty <IViewFilter>();
            ViewData.Remove(ViewFiltersDataKey);


            RenderAdapters.Add(new ViewElementAdapter(viewContext));


            while (viewContext.IsChildAction)
            {
                viewContext = viewContext.ParentActionViewContext;//循环上溯最原始的视图上下文
            }
            RawViewContext = viewContext;


            Url = new UrlHelper(RequestContext);

            HttpContext.Trace.Write("Jumony for MVC", "Begin Process");
            OnPreProcess();
            ProcessMain();
            OnPostProcess();
            HttpContext.Trace.Write("Jumony for MVC", "End Process");


            HttpContext.Trace.Write("Jumony for MVC", "Begin Render");
            OnPreRender(writer);
            var content = RenderContent();

            OnPostRender(writer);
            HttpContext.Trace.Write("Jumony for MVC", "End Render");

            UpdateCache(content);

            writer.Write(content);
        }
예제 #4
0
        /// <summary>
        /// 渲染输出内容
        /// </summary>
        /// <returns>渲染的 HTML</returns>
        protected override string RenderContent()
        {
            EnsurePageView();

            return(Document.Render(RenderAdapters.ToArray()));
        }