本文整理汇总了C#中Parser.FinalizeTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.FinalizeTemplate方法的具体用法?C# Parser.FinalizeTemplate怎么用?C# Parser.FinalizeTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.FinalizeTemplate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CombineVariablesTestWithDescriptions
public void CombineVariablesTestWithDescriptions()
{
const string input =
"Don't {{verb}} each {{#repeater}}and every {{/repeater}}{{time|Days or weeks}} by the {{noun}} you reap{{#includeRest|Includes the rest of the phrase}}, but by the {{otherNoun}}s that you plant{{/includeRest}}.";
var template = new Template
{
Subject = "My {{verb}}",
TextTemplate = input
};
var service = new Parser();
var emailScope = service.InitializeEmail(template);
emailScope.StringVariables.First(a => a.Name == "verb").Value = "judge";
emailScope.BooleanLogics.First(a => a.Name == "repeater").Value = false;
emailScope.StringVariables.First(a => a.Name == "time").Value = "day";
emailScope.StringVariables.First(a => a.Name == "noun").Value = "harvest";
emailScope.BooleanLogics.First(a => a.Name == "includeRest").Value = true;
emailScope.StringVariables.First(a => a.Name == "otherNoun").Value = "seed";
var output = service.FinalizeTemplate(emailScope);
Assert.AreEqual("Don't judge each day by the harvest you reap, but by the seeds that you plant.", output.PlainEmailBody);
Assert.AreEqual("My judge", output.Subject);
Assert.IsTrue(emailScope.StringVariables.First(a => a.Name == "time").Description == "Days or weeks");
Assert.IsTrue(emailScope.StringVariables.First(a => a.Name == "verb").Description == "");
Assert.IsTrue(emailScope.BooleanLogics.First(a => a.Name == "includeRest").Description == "Includes the rest of the phrase");
Assert.IsTrue(emailScope.BooleanLogics.First(a => a.Name == "repeater").Description == "");
}
示例2: CombineVariablesTest
public void CombineVariablesTest()
{
const string plainInput =
"Don't {{verb}} each {{#repeater}}and every {{/repeater}}{{time}} by the {{noun}} you reap{{#includeRest}}, but by the {{otherNoun}}s that you plant{{/includeRest}}.";
const string htmlInput =
"<html><head></head><body><h1>Don't</h1> {{verb}} each {{#repeater}}and every {{/repeater}}{{time}}.</body></html>";
var template = new Template
{
Subject = "This is my {{noun}}",
HtmlTemplate = htmlInput,
TextTemplate = plainInput
};
var service = new Parser();
var emailScope = service.InitializeEmail(template);
emailScope.StringVariables.First(a => a.Name == "verb").Value = "judge";
emailScope.BooleanLogics.First(a => a.Name == "repeater").Value = false;
emailScope.StringVariables.First(a => a.Name == "time").Value = "day";
emailScope.StringVariables.First(a => a.Name == "noun").Value = "harvest";
emailScope.BooleanLogics.First(a => a.Name == "includeRest").Value = true;
emailScope.StringVariables.First(a => a.Name == "otherNoun").Value = "seed";
var output = service.FinalizeTemplate(emailScope);
Assert.AreEqual("Don't judge each day by the harvest you reap, but by the seeds that you plant.", output.PlainEmailBody);
Assert.AreEqual("<html><head></head><body><h1>Don't</h1> judge each day.</body></html>", output.HtmlEmailBody);
Assert.AreEqual("This is my harvest", output.Subject);
}
示例3: CombineDuplicateVariablesTest
public void CombineDuplicateVariablesTest()
{
const string input =
"Don't {{verb}} each {{#repeater}}and every {{/repeater}}{{time}} by the {{noun}} you reap{{#includeRest}}, but by the {{otherNoun}}s that you plant{{/includeRest}}. Yes, {{otherNoun}}s.";
var template = new Template
{
TextTemplate = input
};
var service = new Parser();
var emailScope = service.InitializeEmail(template);
emailScope.StringVariables.First(a => a.Name == "verb").Value = "judge";
emailScope.BooleanLogics.First(a => a.Name == "repeater").Value = false;
emailScope.StringVariables.First(a => a.Name == "time").Value = "day";
emailScope.StringVariables.First(a => a.Name == "noun").Value = "harvest";
emailScope.BooleanLogics.First(a => a.Name == "includeRest").Value = true;
emailScope.StringVariables.First(a => a.Name == "otherNoun").Value = "seed";
var output = service.FinalizeTemplate(emailScope);
Assert.AreEqual("Don't judge each day by the harvest you reap, but by the seeds that you plant. Yes, seeds.", output.PlainEmailBody);
}
示例4: HtmlParseWithNoTagsShouldYieldExpectedOutcome
public void HtmlParseWithNoTagsShouldYieldExpectedOutcome()
{
const string input = "<html><h1>Four scope and seven years ago...";
var template = new Template
{
HtmlTemplate = input
};
var service = new Parser();
var result = service.InitializeEmail(template);
var output = service.FinalizeTemplate(result);
Assert.AreEqual("<html><h1>Four scope and seven years ago...", output.HtmlEmailBody);
}