本文整理汇总了C#中Template.getTokens方法的典型用法代码示例。如果您正苦于以下问题:C# Template.getTokens方法的具体用法?C# Template.getTokens怎么用?C# Template.getTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template.getTokens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testString
public void testString()
{
//-----------------------------------------------------
String html = @"z";
wojilu.Web.Template tpl = new Template().InitContent( html ) as Template;
List<Token> tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
Token x = tokens[0];
Assert.AreEqual( TokenType.String, x.getType() );
Assert.AreEqual( "z", x.getValue() );
//-----------------------------------------------------
html = @""; // 空字符串不进行解析
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 0, tokens.Count );
//-----------------------------------------------------
html = @" "; // 空字符串不进行解析
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 0, tokens.Count );
//-----------------------------------------------------
html = @"zz";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.String, x.getType() );
Assert.AreEqual( "zz", x.getValue() );
//-----------------------------------------------------
html = @" z";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.String, x.getType() );
Assert.AreEqual( " z", x.getValue() );
//-----------------------------------------------------
html = @"z ";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.String, x.getType() );
Assert.AreEqual( "z ", x.getValue() );
//-----------------------------------------------------
html = @" z ";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.String, x.getType() );
Assert.AreEqual( " z ", x.getValue() );
}
示例2: testCodeToken
public void testCodeToken()
{
String html = @"<%%>";
wojilu.Web.Template tpl = new Template().InitContent( html ) as Template;
List<Token> tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
Token x = tokens[0];
Assert.AreEqual( TokenType.Code, x.getType() );
Assert.AreEqual( "", x.getValue() );
//-----------------------------------------------------
html = @"<% %>";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.Code, x.getType() );
Assert.AreEqual( " ", x.getValue() );
//-----------------------------------------------------
html = @"<% %>";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 1, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.Code, x.getType() );
Assert.AreEqual( " ", x.getValue() );
//-----------------------------------------------------
html = @" <%%>";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 2, tokens.Count );
x = tokens[1];
Assert.AreEqual( TokenType.Code, x.getType() );
Assert.AreEqual( "", x.getValue() );
//-----------------------------------------------------
html = @"<%%> ";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 2, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.Code, x.getType() );
Assert.AreEqual( "", x.getValue() );
//-----------------------------------------------------
html = @"x<%%>y";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 3, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.String, x.getType() );
Assert.AreEqual( "x", x.getValue() );
Token n = tokens[1];
Assert.AreEqual( TokenType.Code, n.getType() );
Assert.AreEqual( "", n.getValue() );
Token y = tokens[2];
Assert.AreEqual( TokenType.String, y.getType() );
Assert.AreEqual( "y", y.getValue() );
//-----------------------------------------------------
html = @"x<% %>y";
tpl = new Template().InitContent( html ) as Template;
tokens = tpl.getTokens();
Assert.AreEqual( 3, tokens.Count );
x = tokens[0];
Assert.AreEqual( TokenType.String, x.getType() );
Assert.AreEqual( "x", x.getValue() );
n = tokens[1];
Assert.AreEqual( TokenType.Code, n.getType() );
Assert.AreEqual( " ", n.getValue() );
y = tokens[2];
Assert.AreEqual( TokenType.String, y.getType() );
Assert.AreEqual( "y", y.getValue() );
}