Пример #1
0
        public async Task RenderIncludedTemplateAsync <T>(
            ITemplatePage templatePage,
            T model,
            TextWriter textWriter,
            ExpandoObject viewBag,
            TemplateRenderer templateRenderer)
        {
            SetModelContext(templatePage, textWriter, model, viewBag);

            templateRenderer.RazorPage = templatePage;
            await templateRenderer.RenderAsync().ConfigureAwait(false);
        }
Пример #2
0
        /// <summary>
        /// Renders a template to the specified <paramref name="textWriter"/>
        /// </summary>
        /// <param name="templatePage">Instance of a template</param>
        /// <param name="model">Template model</param>
        /// <param name="modelType">Type of the model</param>
        /// <param name="viewBag">Dynamic viewBag of the page</param>
        /// <param name="textWriter">Output</param>
        public async Task RenderTemplateAsync <T>(
            ITemplatePage templatePage,
            T model,
            TextWriter textWriter,
            ExpandoObject viewBag = null)
        {
            SetModelContext(templatePage, textWriter, model, viewBag);

            using (var scope = new MemoryPoolViewBufferScope())
            {
                var renderer = new TemplateRenderer(templatePage, this, HtmlEncoder.Default, scope);

                await renderer.RenderAsync().ConfigureAwait(false);
            }
        }