/// <summary> /// Initializes a new instance of the <see cref="CSF.Zpt.Tales.TemplateFile"/> class. /// </summary> /// <param name="document">Document.</param> public TemplateFile(IZptDocument document) { if(document == null) { throw new ArgumentNullException(nameof(document)); } _document = document; }
public IZptDocument GetDocument() { if(_document == null) { _document = _documentCreator(); } return _document; }
/// <summary> /// Initializes a new instance of the <see cref="CSF.Zpt.DocumentProviders.ZptHtmlElement"/> class. /// </summary> /// <param name="node">The source HTML node.</param> /// <param name="sourceFile">Information about the element's source file.</param> /// <param name="isRoot">Whether or not this is the root element.</param> /// <param name="isImported">Whether or not this element is imported.</param> /// <param name="ownerDocument">The ZPT document which owns the element.</param> public ZptHtmlElement(HtmlNode node, ISourceInfo sourceFile, IZptDocument ownerDocument, bool isRoot = false, bool isImported = false) : base(sourceFile, isRoot, isImported, ownerDocument) { if(node == null) { throw new ArgumentNullException(nameof(node)); } _node = node; }
/// <summary> /// Renders a single ZPT document and returns a response. /// </summary> /// <param name="doc">The document to render.</param> /// <param name="outputStream">The output stream.</param> /// <param name="options">Rendering options.</param> /// <param name="contextConfigurator">Context configurator.</param> /// <param name="outputInfo">Output info.</param> protected override IBatchRenderingDocumentResponse Render(IZptDocument doc, Stream outputStream, IRenderingSettings options, Action<IModelValueContainer> contextConfigurator, string outputInfo) { try { return base.Render(doc, outputStream, options, contextConfigurator, outputInfo); } catch(ZptException ex) { return new BatchRenderingDocumentResponse(doc.GetSourceInfo(), ex); } }
/// <summary> /// Initializes a new instance of the <see cref="T:CSF.Screenplay.Reporting.Models.ReportDocument"/> class. /// </summary> /// <param name="report">The Screenplay report to render.</param> /// <param name="document">The ZPT document.</param> public ReportDocument(IReport report, IZptDocument document) { if (document == null) { throw new ArgumentNullException(nameof(document)); } if (report == null) { throw new ArgumentNullException(nameof(report)); } this.report = new ReportModel(report); this.document = document; }
/// <summary> /// Initializes a new instance of the <see cref="CSF.Zpt.DocumentProviders.ZptXmlLinqElement"/> class. /// </summary> /// <param name="node">The source XML Node.</param> /// <param name="sourceFile">Information about the element's source file.</param> /// <param name="isRoot">Whether or not this is the root element.</param> /// <param name="isImported">Whether or not this element is imported.</param> /// <param name="ownerDocument">The ZPT document which owns the element.</param> public ZptXmlLinqElement(XNode node, ISourceInfo sourceFile, IZptDocument ownerDocument, bool isRoot = false, bool isImported = false) : base(sourceFile, isRoot, isImported, ownerDocument) { if(node == null) { throw new ArgumentNullException(nameof(node)); } _node = node as XElement; if(_node.NodeType == XmlNodeType.Document) { _node = node.Document.Root; } EnforceNodeType("XML", XmlNodeType.Element, _node.NodeType); }
/// <summary> /// Renders a single ZPT document and returns a response. /// </summary> /// <param name="doc">The document to render.</param> /// <param name="outputStream">The output stream.</param> /// <param name="options">Rendering options.</param> /// <param name="contextConfigurator">Context configurator.</param> /// <param name="outputInfo">Output info.</param> protected virtual IBatchRenderingDocumentResponse Render(IZptDocument doc, Stream outputStream, IRenderingSettings options, Action<IModelValueContainer> contextConfigurator, string outputInfo) { using(var writer = new StreamWriter(outputStream, options.OutputEncoding)) { doc.Render(writer, options: options, contextConfigurator: contextConfigurator); } return new BatchRenderingDocumentResponse(doc.GetSourceInfo(), outputInfo); }
/// <summary> /// Creates a template file from the given ZPT document. /// </summary> /// <returns>The template file.</returns> /// <param name="document">Document.</param> public Tales.TemplateFile CreateTemplateFile(IZptDocument document) { return new Tales.TemplateFile(document); }
protected override string Render(IZptDocument document, IRenderingSettings options) { return document.Render(_model, options); }
ReportDocument GetDocumentModel(IReport reportModel, IZptDocument document) => new ReportDocument(reportModel, document);
protected virtual string Render(IZptDocument document, IRenderingSettings options) { return document.Render(options); }