public async Task LoadForm_should_throw_meaningful_exception_if_cannot_parse_the_element() { var text = "<Form><unknown /></Form>"; var loader = new FormLoader(); var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => loader.LoadForm(new StringReader(text))); ex.Message.ShouldBe("Unable to parse element 'unknown' - no corresponding type were registered"); }
public async Task LoadForm_should_throw_meaningful_exception_if_cannot_parse_form_element() { var text = "<Something/>"; var loader = new FormLoader(); var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => loader.LoadForm(new StringReader(text))); ex.Message.ShouldBe("Expected 'Form' element, but got 'Something'"); }
public async Task Compile(string name, string snippet) { var form = await _loader.LoadForm(new StringReader(snippet)); WrapForm(form); var opt = new BitmapRendererOptions { ConfigureGraphics = g => { g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; } }; using (var bmp = _renderer.Render(form, opt)) { bmp.Save($"man\\assets\\{name}"); } }
private async Task <byte[]> Generate() { var form = await _loader.LoadForm(new MemoryStream(_formInBytes)); var pdf = new PdfDocument(); _renderer.Render(form, pdf.AddPage(), new PdfRendererOptions { AdjustPageSize = true }); _renderer.Render(form, pdf.AddPage(), new PdfRendererOptions { ConfigureGraphics = x => x.ScaleTransform(0.5, 0.5) }); using (var mem = new MemoryStream()) { pdf.Save(mem); return(mem.ToArray()); } }
private async Task <Bitmap> Generate() { var form = await _loader.LoadForm(new MemoryStream(_formInBytes)); return(_renderer.Render(form)); }