Beispiel #1
0
        private string RazorOutputFile(object tableData, object model,
                                       object pageData, string RazorFile, bool isEdit, int?index = null)
        {
            var          viewBag = GetNewViewBag(tableData, pageData, CreateCustomData(isEdit), index);
            IRazorEngine engine  = RazorEnginePlugInFactory.CreateRazorEngine(RazorUtil.MULTIEDIT_ENGINE_NAME);

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

            return(content);
        }
        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));
        }
        private static string Execute(object model, dynamic viewBag, PageTemplateInitData initData,
                                      string razorFile, string layout, IPageTemplate pageTemplate, ISource source,
                                      IInputData input, OutputData outputData)
        {
            string engineName = pageTemplate.GetEngineName(source, input, outputData);

            IRazorEngine engine = RazorEnginePlugInFactory.CreateRazorEngine(engineName);

            string content = Task.Run(async()
                                      => await RazorExtension.CompileRenderWithLayoutAsync(engine, razorFile,
                                                                                           layout, model, initData, viewBag)).GetAwaiter().GetResult();

            return(content);
        }