public async Task WriteStreamAsync(Stream stream, AnalyzeResponse response) { using (var scope = _factory.CreateScope()) { var model = new RazorHtmlObject(response, _targetMapper); var helper = scope.ServiceProvider.GetRequiredService <RazorViewToStringRenderer>(); await helper.RenderViewAsync("Views/ReportTemplate.cshtml", model, stream); } }
public void WriteStream(Stream stream, AnalyzeResponse response) { const string ReportTemplateName = "ReportTemplate"; using (var writer = new StreamWriter(stream)) { var reportObject = new RazorHtmlObject(response, _targetMapper); var mainTemplate = Resolve(ReportTemplateName); var razor = _razorService.RunCompile(mainTemplate, ReportTemplateName, typeof(RazorHtmlObject), reportObject); writer.Write(razor); } }