public IContent WritePage(ISource source, IPageData pageData, OutputData outputData)
        {
            IPageTemplate template = CreatePageTemplate(PageTemplateName);

            if (Scripts == null)
            {
                Scripts = new UserScript(null);
            }
            object pageDataObj = PageData;

            if (pageDataObj == null)
            {
                pageDataObj = template.GetDefaultPageData(source, pageData, outputData);
            }
            if (pageDataObj != null)
            {
                OnSetPageData(new PageDataEventArgs(source, pageData, outputData, pageDataObj));
            }

            object model = WebRazorUtil.GetModel(outputData);

            var    viewBag = WebRazorUtil.GetNewViewBag(pageData, fMetaData, Scripts, pageDataObj);
            string content = Execute(template, PageTemplateName, ModelCreator, RazorFile,
                                     WebRazorUtil.GetModel(outputData), viewBag, source, pageData, outputData);

            return(new SimpleContent(ContentTypeConst.HTML, content));
        }
Ejemplo n.º 2
0
        public IContent WritePage(ISource source, IPageData pageData, OutputData outputData)
        {
            object       model   = WebRazorUtil.GetModel(outputData);
            var          viewBag = WebRazorUtil.GetViewBag(pageData, fMetaData, null, RazorData);
            IRazorEngine engine  = RazorEnginePlugInFactory.CreateRazorEngine(EngineName);

            string fileName = UseTemplate ? WebRazorUtil.GetTemplateFile(fFileName) : fFileName;

            string content = Task.Run(async()
                                      => await RazorExtension.CompileRenderWithLayoutAsync(engine, fileName,
                                                                                           Layout, model, null, viewBag)).GetAwaiter().GetResult();

            return(new SimpleContent(ContentTypeConst.HTML, content));
        }