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));
        }
예제 #2
0
        internal static dynamic GetNewViewBag(IPageData page, IMetaData metaData,
                                              UserScript script, object pageData)
        {
            dynamic viewBag = new ExpandoObject();

            viewBag.Title = page.Title;
            if (metaData != null)
            {
                viewBag.MetaData = metaData;
                string title = metaData.Title;
                if (!string.IsNullOrEmpty(title))
                {
                    viewBag.Title = title;
                }
            }
            if (script != null)
            {
                viewBag.Script = script;
            }
            if (pageData != null)
            {
                viewBag.PageData = pageData;
            }

            return(viewBag);
        }
예제 #3
0
        internal static dynamic GetViewBag(IPageData page, IMetaData metaData, UserScript script,
                                           IConfigCreator <object> pageData)
        {
            object pd = null;

            if (pageData != null)
            {
                pd = pageData.CreateObject();
            }
            return(GetNewViewBag(page, metaData, script, pd));
        }
 internal void SetConfig(BaseRazorPageTemplatePageMakerConfig config)
 {
     if (config != null)
     {
         RazorFile = config.RazorFile;
         if (config.RazorData != null)
         {
             PageData = config.RazorData.CreateObject();
         }
         Scripts      = new UserScript(config.Scripts);
         ModelCreator = config.ModelCreator;
     }
 }