public Task BeginWriteDocumentAsync(DocumentRenderModel model, DocumentInstructionContextV1 context) { if (_isRendering || _isComplete) { throw new InvalidOperationException("Document writing already started"); } _isRendering = true; return(Task.CompletedTask); }
private async Task <SerializableDocument> GetResultAsync(string markup, DocumentRenderModel model = null) { var builder = new SerializableDocumentBuilderV1(); await new DocumentInstructorV1().InstructRenderingAsync( @"<document><page><inline>1<data>reference</data></inline></page></document>", model ?? new DocumentRenderModel() { Items = Enumerable.Empty <DocumentRenderModelItem>() }, builder); return(builder.Result); }
public async Task InstructRenderingAsync(string markup, DocumentRenderModel model, IDocumentBuilderV1 builder) { if (_context != null) { throw new InvalidOperationException(); } _context = new DocumentInstructionContextV1(); _builder = builder; _model = model; _listItemIndexContinueOffsetByNestingLevel = new Dictionary <int, int>(); XDocument document = null; using (var sr = new StringReader(markup)) { document = XDocument.Load(sr); } var root = document.Root; var valuesByReference = _model.Items.ToDictionary(i => i.Reference, i => i.Value); _context = _context.BeforeBegin(document.Root.Name.LocalName, hasContent: document.Root.HasContent()); await builder.BeginWriteDocumentAsync(model, _context); _context = _context.AfterBegin(); foreach (var page in root.Elements()) { await WriteConditionalElementAsync(page, valuesByReference, async() => { await InstructPageRenderingAsync(page, valuesByReference); }); } _context = _context.BeforeEnd(); await builder.EndWriteDocumentAsync(_context); _context = _context.AfterEnd(); }
public Task BeginWriteDocumentAsync(DocumentRenderModel model, DocumentInstructionContextV1 context) { _pages = new List <string>(); return(Task.CompletedTask); }