本文整理汇总了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);
}