本文整理汇总了C#中System.Factory.Text方法的典型用法代码示例。如果您正苦于以下问题:C# Factory.Text方法的具体用法?C# Factory.Text怎么用?C# Factory.Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Factory
的用法示例。
在下文中一共展示了Factory.Text方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollapsesPreviousWhiteSpace
public void CollapsesPreviousWhiteSpace()
{
var factory = new Factory();
// "Hello {{~test}}"
var document = factory.Document(
factory.Text("Hello"),
factory.WhiteSpace(1),
factory.Expression(
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("~", T.Tilde),
factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)),
factory.MetaCode("}}", T.CloseTag)));
factory = new Factory();
// "Hello{{~test}}"
var expected = factory.Document(
factory.Text("Hello"),
factory.WhiteSpace(1, collapsed: true),
factory.Expression(
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("~", T.Tilde),
factory.Span(SpanKind.Expression, factory.Symbol("this", T.Identifier)),
factory.MetaCode("}}", T.CloseTag)));
var visitor = new WhiteSpaceCollapsingParserVisitor();
visitor.VisitBlock(document);
var builder = new StringBuilder();
var comparer = new EquivalanceComparer(builder, 0);
Assert.True(comparer.Equals(expected, document), builder.ToString());
}
示例2: CollapsesWhiteSpaceInParentBlocks
public void CollapsesWhiteSpaceInParentBlocks()
{
var factory = new Factory();
// "Message:{{#this~}} Hello {{~/this~}} There"
var document = factory.Document(
factory.Text("Message:"),
factory.Tag("this",
factory.TagElement("this",
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("#", T.Hash),
factory.Expression(factory.Parameter("this")),
factory.MetaCode("~", T.Tilde),
factory.MetaCode("}}", T.CloseTag)),
factory.WhiteSpace(1),
factory.Text("Hello"),
factory.WhiteSpace(1),
factory.TagElement("this",
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("~", T.Tilde),
factory.MetaCode("/", T.Slash),
factory.Expression(factory.Parameter("this")),
factory.MetaCode("~", T.Tilde),
factory.MetaCode("}}", T.CloseTag))),
factory.WhiteSpace(1),
factory.Text("There"));
factory = new Factory();
// "Message:{{#this~}}Hello{{~/this~}}There"
var expected = factory.Document(
factory.Text("Message:"),
factory.Tag("this",
factory.TagElement("this",
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("#", T.Hash),
factory.Expression(factory.Parameter("this")),
factory.MetaCode("~", T.Tilde),
factory.MetaCode("}}", T.CloseTag)),
factory.WhiteSpace(1, collapsed: true),
factory.Text("Hello"),
factory.WhiteSpace(1, collapsed: true),
factory.TagElement("this",
factory.MetaCode("{{", T.OpenTag),
factory.MetaCode("~", T.Tilde),
factory.MetaCode("/", T.Slash),
factory.Expression(factory.Parameter("this")),
factory.MetaCode("~", T.Tilde),
factory.MetaCode("}}", T.CloseTag))),
factory.WhiteSpace(1, collapsed: true),
factory.Text("There"));
var visitor = new WhiteSpaceCollapsingParserVisitor();
visitor.VisitBlock(document);
var builder = new StringBuilder();
var comparer = new EquivalanceComparer(builder, 0);
Assert.True(comparer.Equals(expected, document), builder.ToString());
}