Пример #1
0
        private async Task RenderPageCoreAsync(ITemplatePage page, PageContext context)
        {
            page.PageContext = context;
            page.IncludeFunc = async(key, model) =>
            {
                ITemplatePage template = await _engine.CompileTemplateAsync(key);

                await _engine.RenderTemplateAsync(template, model, model?.GetType(), context.Writer, context.ViewBag);
            };

            //_pageActivator.Activate(page, context);

            await page.ExecuteAsync().ConfigureAwait(false);
        }
        public IEnumerable <string> StreamTo(IDataToSent dataToSent)
        {
            var found = engine.TemplateCache.RetrieveTemplate(key);

            if (!found.Success)
            {
                throw new ArgumentException(" the template was not initialized");
            }
            foreach (var item in dataToSent.DataToBeSentFurther)
            {
                var res = engine.RenderTemplateAsync(found.Template.TemplatePageFactory(), item.Value).ConfigureAwait(false).GetAwaiter().GetResult();

                yield return(res);
            }
        }