示例#1
0
        /// <inheritdoc/>
        public void Render(ViewContext context, TextWriter writer)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (context.ViewData.Model is TModel m)
            {
                var html = _view.Render(m);
                html.Write(writer);
                return;
            }
            throw new InvalidOperationException($"Expected a model of type {typeof(TModel).Name} but the actual model is of type {context.ViewData.Model.GetType().Name}");
        }
示例#2
0
        /// <inheritdoc/>
        public async Task RenderAsync(ViewContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (context.ViewData.Model is TModel m)
            {
                var html = _view.Render(m);

                if (context.ViewData.TryGetValue("RenderAsync", out var renderAsync) && renderAsync is bool b && b)
                {
                    await html.WriteAsync(context.Writer);

                    return;
                }
                html.Write(context.Writer);
                return;
            }
            throw new InvalidOperationException($"Expected a model of type {typeof(TModel).Name} but the actual model is of type {context.ViewData.Model.GetType().Name}");
        }
示例#3
0
 private async Task Render(SolutionConfiguration solutionConfiguration, SolutionList solutionList)
 {
     await _htmlRenderer.Render(solutionConfiguration, solutionList);
 }