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


C# StringScanner.Get方法代码示例

本文整理汇总了C#中StringScanner.Get方法的典型用法代码示例。如果您正苦于以下问题:C# StringScanner.Get方法的具体用法?C# StringScanner.Get怎么用?C# StringScanner.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringScanner的用法示例。


在下文中一共展示了StringScanner.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Selectors

        public void Selectors()
        {
            scanner = "div:contains('Product')";
            string text = scanner.Get(MatchFunctions.HTMLTagName );
            Assert.AreEqual("div", text, "Got the first part");
            scanner.Expect(":");
            text = scanner.Get(MatchFunctions.PseudoSelector);
            Assert.AreEqual("contains", text, "Got the 2nd part");

            text = scanner.Get(MatchFunctions.Bounded);
            Assert.AreEqual("'Product'", text, "Got the 3rdd part");

        }
开发者ID:fluffysquirrels,项目名称:ProgNet2012-Completed,代码行数:13,代码来源:StringScanner.cs

示例2: StringParsing

        public void StringParsing()
        {
            string test = @"someSelect[attr-bute= 'this is \' a quoted value']";
            scanner = test;
            scanner.IgnoreWhitespace = true;

            var text = scanner.GetAlpha();
            Assert.AreEqual("someSelect", text, "Got first word");

            Assert.Throws(typeof(InvalidOperationException), Del(() =>
            {
                scanner.Expect(MatchFunctions.Quoted);
            }), "Bounds don't work with quoted value");

            scanner.Expect(MatchFunctions.BoundChar);

            text = scanner.Get(MatchFunctions.HTMLAttribute);
            Assert.AreEqual("attr-bute", text, "Got attribue");

            scanner.ExpectChar('=');

            text = scanner.Get(MatchFunctions.Quoted);

            Assert.AreEqual("this is ' a quoted value", text, "Got first word");
            Assert.AreEqual(scanner.NextChar, ']', "At right postiion");


        }
开发者ID:fluffysquirrels,项目名称:ProgNet2012-Completed,代码行数:28,代码来源:StringScanner.cs

示例3: BuiltInSelectors

        public void BuiltInSelectors()
        {
            [email protected]"someSelect[attr-bute= 'this ""is \' a quoted value']";

            var text = scanner.Get(MatchFunctions.HTMLTagName);
            Assert.AreEqual("someSelect", text, "Got first word");

            StringScanner innerScanner = scanner.Get(MatchFunctions.BoundedWithQuotedContent);
            Assert.IsTrue(scanner.Finished, "Outer scanner finished");
            Assert.AreEqual(@"attr-bute= 'this ""is \' a quoted value'", innerScanner.Text, "Inner scanner text is right");

            text = innerScanner.Get(MatchFunctions.HTMLAttribute);
            Assert.AreEqual("attr-bute", text, "Got the attribute name");
            innerScanner.Expect("=");
            text = innerScanner.Get(MatchFunctions.Quoted);
            Assert.AreEqual(@"this ""is ' a quoted value", text, "Quotes were dequoted");
            Assert.IsTrue(innerScanner.Finished, "It's finished after we got the last text");

            scanner = @"<comment>How's complex bounding working?</comment> the end";
            text = scanner.GetBoundedBy("<comment>", "</comment>");
            Assert.AreEqual(@"How's complex bounding working?", text, "Complex bounding worked");
            Assert.AreEqual(' ', scanner.NextChar, "At the right place");
            
            Assert.IsTrue(scanner.ExpectAlpha().ExpectAlpha().Finished, "At the end");


        }
开发者ID:fluffysquirrels,项目名称:ProgNet2012-Completed,代码行数:27,代码来源:StringScanner.cs


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