コード例 #1
0
 public static async Task RenderIncludedTemplateAsync <T>(ITemplatePage parentPage, BasePage <T> includedTemplatePage, T model)
 {
     using (var scope = new MemoryPoolViewBufferScope())
     {
         var renderer = new TemplateRenderer(Handler, HtmlEncoder.Default, scope);
         SetModelContext(includedTemplatePage, parentPage.PageContext.Writer, model, parentPage.PageContext.ViewBag);
         await renderer.RenderAsync(includedTemplatePage).ConfigureAwait(false);
     }
 }
コード例 #2
0
        ///// <summary>
        ///// Gets the sequence of _ViewStart <see cref="ITemplatePage"/> instances that are executed by this view.
        ///// </summary>
        //public IReadOnlyList<ITemplatePage> ViewStartPages { get; }

        /// <inheritdoc />
        public virtual async Task RenderAsync()
        {
            var context = RazorPage.PageContext;

            _bufferScope = new MemoryPoolViewBufferScope();

            var bodyWriter = await RenderPageAsync(RazorPage, context, invokeViewStarts : false).ConfigureAwait(false);

            await RenderLayoutAsync(context, bodyWriter).ConfigureAwait(false);
        }
コード例 #3
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);
            }
        }