本文整理汇总了C#中ITemplate.Get方法的典型用法代码示例。如果您正苦于以下问题:C# ITemplate.Get方法的具体用法?C# ITemplate.Get怎么用?C# ITemplate.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITemplate
的用法示例。
在下文中一共展示了ITemplate.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
/// <summary>
/// Set template variable value with data from template (all occurrences will be replaced)
/// </summary>
/// <param name="variableName">Variable name in master template file</param>
/// <param name="template">The template.</param>
public void Add(string variableName, ITemplate template)
{
if (template == null)
return;
Add(variableName, template.Get());
}
示例2: Tpl
/// <summary>
/// Initializes a new instance of the <see cref="Tpl" /> class.
/// </summary>
/// <param name="template">The template.</param>
/// <param name="title">The site title.</param>
public Tpl(ITemplate template, string title)
{
if (template != null)
Data = template.Get();
Title = title;
}
示例3: InlineTpl
/// <summary>
/// Initializes a new instance of the <see cref="InlineTpl"/> class.
/// </summary>
/// <param name="dataCollectorVariableName">Name of the data collector variable.</param>
/// <param name="template">The template.</param>
public InlineTpl(string dataCollectorVariableName, ITemplate template)
{
if (string.IsNullOrEmpty(dataCollectorVariableName))
throw new ArgumentNullException(nameof(dataCollectorVariableName));
DataCollectorVariableName = dataCollectorVariableName;
if (template != null)
Data = template.Get();
}
示例4: Set_EverythingIsNull_SetCorrectly
public void Set_EverythingIsNull_SetCorrectly()
{
// Assign
_template = Template.FromString("{Model.ID} {Model.Name} {Model.EMail}");
var model = new TestModel();
// Act
_template.Model(model).Set();
// Assert
Assert.AreEqual(" ", _template.Get());
}
示例5: TestTemplate
private static void TestTemplate(ITemplate tpl, ITemplate masterTemplate, ITemplate testTemplate, ITemplate masterTestTemplate)
{
masterTemplate.Set("Title", "Hello world!!!");
tpl.Set("ItemTitle", "Item1");
tpl.Add("var1", 15.5m);
tpl.Add("var1", (long)16);
tpl.Add("var1", 17);
tpl.Add("var1", 18.16);
tpl.Add("var1", new object());
tpl.Set("var2", 15.5m)
.Set("var3", (long)16)
.Set("var4", 17)
.Set("var5", 18.16)
.Set("var6", new object());
Assert.AreEqual(testTemplate.Get(), tpl.Get());
masterTemplate.Add("Items", tpl.GetAndRoll());
tpl.Set("ItemTitle", "Item2");
tpl.Add("var1", 16.5m)
.Add("var1", (long)255)
.Add("var1", 300)
.Add("var1", 26.15)
.Add("var1", new object());
tpl.Set("var2", 10.5m);
tpl.Set("var3", (long)1);
tpl.Set("var4", 3);
tpl.Set("var5", 4.1233);
tpl.Set("var6", new object());
tpl.Set("NotFoundItem", (ITemplate)null);
masterTemplate.Add("Items", tpl);
Assert.AreEqual(masterTestTemplate.Get(), masterTemplate.Get());
}
示例6: Set
/// <summary>
/// Set template variable value with text from template (all occurrences will be replaced)
/// </summary>
/// <param name="variableName">Variable name</param>
/// <param name="template">Value to set</param>
public ITemplate Set(string variableName, ITemplate template)
{
return template != null ? Set(variableName, template.Get()) : this;
}