当前位置: 首页>>代码示例>>C#>>正文


C# IServices.AssembleDocument方法代码示例

本文整理汇总了C#中IServices.AssembleDocument方法的典型用法代码示例。如果您正苦于以下问题:C# IServices.AssembleDocument方法的具体用法?C# IServices.AssembleDocument怎么用?C# IServices.AssembleDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServices的用法示例。


在下文中一共展示了IServices.AssembleDocument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssembleDocument

        private void AssembleDocument(IServices svc, string logRef)
        {
            Template tmp = Util.OpenTemplate("d1f7cade-cb74-4457-a9a0-27d94f5c2d5b");
            TextReader answers = new StringReader("");
            AssembleDocumentSettings settings = new AssembleDocumentSettings();
            AssembleDocumentResult result;

            // Verify that a null template throws the right exception.
            try
            {
                result = svc.AssembleDocument(null, answers, settings, logRef);
                Assert.Fail(); // We should not have reached this point.
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.Message.Contains("template"));
            }
            catch (Exception)
            {
                Assert.Fail(); // We are not expecting a generic exception.
            }

            // Pass a null for settings, answers, and logRef to ensure that defaults are used.
            result = svc.AssembleDocument(tmp, null, null, null);
            Assert.AreEqual(result.PendingAssembliesCount, 0);
            Assert.AreEqual(0, result.Document.SupportingFiles.Count<NamedStream>());
            Assert.AreEqual(0, result.PendingAssembliesCount); ;

            settings.Format = DocumentType.MHTML;
            result = svc.AssembleDocument(tmp, answers, settings, logRef);
            Assert.AreEqual(0, result.Document.SupportingFiles.Count<NamedStream>()); // The MHTML is a single file (no external images).

            settings.Format = DocumentType.HTMLwDataURIs;
            result = svc.AssembleDocument(tmp, answers, settings, logRef);
            Assert.AreEqual(0, result.Document.SupportingFiles.Count<NamedStream>()); // The HTML with Data URIs is a single file (no external images).

            settings.Format = DocumentType.HTML;
            result = svc.AssembleDocument(tmp, answers, settings, logRef);
            Assert.AreEqual(1, result.Document.SupportingFiles.Count<NamedStream>()); // The HTML contains one external image file.

            //Assemble a document with an answer file containing a transient answer.
            string transAnsPath = Path.Combine(Util.GetTestAnswersDir(), "TransAns.anx");
            TextReader transAns = new StreamReader(new FileStream(transAnsPath, FileMode.Open));
            result = svc.AssembleDocument(tmp, transAns, null, logRef);

            // Now try with another template, which contains an ASSEMBLE instruction.
            tmp = Util.OpenTemplate("TemplateWithAssemble");
            result = svc.AssembleDocument(tmp, null, null, logRef);
            Assert.AreEqual(1, result.PendingAssembliesCount);
        }
开发者ID:MMetodiew,项目名称:hotdocs-open-sdk,代码行数:50,代码来源:ServicesTest.cs


注:本文中的IServices.AssembleDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。