本文整理汇总了C#中Block.Render方法的典型用法代码示例。如果您正苦于以下问题:C# Block.Render方法的具体用法?C# Block.Render怎么用?C# Block.Render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.Render方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: It_supports_accessing_members_of_child_objects
public void It_supports_accessing_members_of_child_objects()
{
var a = new Block("a.b", new LiteralText("c"));
var writer = new StringWriter();
var context = new RenderContext(null, new { a = new { b = new[] { 1, 2, 3 } } }, writer, null);
a.Render(context);
Assert.AreEqual("ccc", writer.GetStringBuilder().ToString());
}
示例2: It_renders_its_child_parts_once_for_each_item_if_name_evaluates_to_a_collection
public void It_renders_its_child_parts_once_for_each_item_if_name_evaluates_to_a_collection()
{
var a = new Block("a", new LiteralText("b"));
var writer = new StringWriter();
var context = new RenderContext(null, new { a = new [] { 1, 2, 3 } }, writer, null);
a.Render(context);
Assert.AreEqual("bbb", writer.GetStringBuilder().ToString());
}
示例3: It_does_not_render_its_child_parts_if_name_evaluates_to_empty_string
public void It_does_not_render_its_child_parts_if_name_evaluates_to_empty_string()
{
var a = new Block("a", new LiteralText("b"));
var writer = new StringWriter();
var context = new RenderContext(null, new { a = "" }, writer, null);
a.Render(context);
Assert.AreEqual("", writer.GetStringBuilder().ToString());
}
示例4: It_renders_its_child_parts_if_name_evaluates_to_true
public void It_renders_its_child_parts_if_name_evaluates_to_true()
{
var a = new Block("a", new LiteralText("b"));
var writer = new StringWriter();
var context = new RenderContext(null, new { a = true }, writer, null, Options.Defaults());
a.Render(context);
Assert.AreEqual("b", writer.GetStringBuilder().ToString());
}
示例5: It_does_not_treat_dictionaries_as_lists
public void It_does_not_treat_dictionaries_as_lists()
{
var a = new Block("a", new LiteralText("x"));
var writer = new StringWriter();
var context = new RenderContext(
null,
new { a = new Dictionary<string, int> { { "b", 1 }, { "c", 2 }, { "d", 3 } } },
writer,
null);
a.Render(context);
Assert.AreEqual("x", writer.GetStringBuilder().ToString());
}
示例6: It_Nested_Fully_Qualified_Statements_Are_Evaluated
public void It_Nested_Fully_Qualified_Statements_Are_Evaluated()
{
var a = new Block("a.b",
new Block("a.c", new LiteralText("I should render."), new EndSection("a.c")),
new EndSection("a.b"));
var writer = new StringWriter();
var context = new RenderContext(
null,
new Dictionary<string, object> { { "a", new Dictionary<string, object> { { "b", 3 }, { "c", true } } } },
writer,
null);
a.Render(context);
Assert.AreEqual("I should render.", writer.GetStringBuilder().ToString());
}