当前位置: 首页>>代码示例>>C#>>正文


C# Template.getTokens方法代码示例

本文整理汇总了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() );
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:71,代码来源:TemplateNew.cs

示例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() );
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:95,代码来源:TemplateNew.cs


注:本文中的Template.getTokens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。