コード例 #1
0
ファイル: TemplateFile.cs プロジェクト: csf-dev/ZPT-Sharp
        /// <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;
        }
コード例 #2
0
ファイル: RenderingJob.cs プロジェクト: csf-dev/ZPT-Sharp
        public IZptDocument GetDocument()
        {
            if(_document == null)
              {
            _document = _documentCreator();
              }

              return _document;
        }
コード例 #3
0
ファイル: ZptHtmlElement.cs プロジェクト: csf-dev/ZPT-Sharp
        /// <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;
        }
コード例 #4
0
 /// <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);
       }
 }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
ファイル: BatchRenderer.cs プロジェクト: csf-dev/ZPT-Sharp
        /// <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);
        }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
 protected override string Render(IZptDocument document, IRenderingSettings options)
 {
     return document.Render(_model, options);
 }
コード例 #10
0
 ReportDocument GetDocumentModel(IReport reportModel, IZptDocument document)
 => new ReportDocument(reportModel, document);
コード例 #11
0
 protected virtual string Render(IZptDocument document, IRenderingSettings options)
 {
     return document.Render(options);
 }