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


C# Token.ReadUntil方法代码示例

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


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

示例1: CssRule

        public CssRule(Token token)
        {
            _selectorStacks = new List<CssSelectorStack>();
            _statements = new List<CssStatement>();

            string data = token.ReadUntil('{');
            token.MovePast("{");

            foreach (var stack in data.Split(',').Select(CssSelectorStack.Parse).Where(stack => stack != null))
                _selectorStacks.Add(stack);

            var statements = token.ReadUntil('}').Split(';').Select(s => s.Trim()).Where(s => !string.IsNullOrEmpty(s)).ToArray();
            foreach (string statement in statements)
            {
                _statements.Add(new CssStatement(statement));
            }
            token.MovePast("}");
        }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:18,代码来源:CssRule.cs

示例2: HtmlTag

        public HtmlTag(Token token)
        {
            token.Next();
            Name = token.ReadUntil(' ', '/', '>');

            ReadAttributes(token);
            Attributes.Changed += OnAttributesChanged;

            _styles = new HtmlStyleCollection();
            _styles.Changed += OnStylesChanged;
            UpdateStyles();

            token.MoveToContent();

            Closed = token.Peeks('/');

            token.MovePast(">");
        }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:18,代码来源:HtmlTag.cs

示例3: ReadAttributes

 protected void ReadAttributes(Token token)
 {
     var done = false;
     while (!done)
     {
         token.MoveToContent();
         if (token.Peeks("/>") || token.Peeks(">") || token.IsDone)
             done = true;
         else
         {
             string attributeName = token.ReadUntil(' ', '=');
             token.MovePast("=");
             token.MoveToContent();
             string attributeValue;
             if (token.Current == '\'' || token.Current == '"')
             {
                 char delimiter = token.Current;
                 token.Next();
                 attributeValue = token.ReadUntil(delimiter);
                 token.Next();
             }
             else
                 attributeValue = token.ReadUntil(' ', '/', '>');
             _attributes[attributeName] = attributeValue;
         }
     }
 }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:27,代码来源:HtmlElement.cs

示例4: Parse

        internal static void Parse(IHtmlElementCollection parent, Token token)
        {
            HtmlElement element = null;
            if (token.Peeks("</"))
                element = new HtmlEndTag(token);
            else if (token.Peeks("<!DOCTYPE"))
                element = new HtmlDocType(token);
            else if (token.Peeks("<!--"))
                element = new HtmlComment(token);
            else if (token.Current == '<')
                element = new HtmlTag(token);
            else
                element = new HtmlContent(token);

            element.Parent = parent;
            parent.ChildElements.Add(element);

            if (element is HtmlTag)
            {
                var tag = (HtmlTag)element;
                if (tag.IsType("script"))
                {
                    HtmlContent script = new HtmlContent(token.ReadUntil("</script>"));
                    tag.ChildElements.Add(script);
                }
            }

            if (element.ElementType != HtmlElementType.EndTag)
                return;

            var tagName = ((HtmlEndTag) element).TagName;
            int startTagIdex = parent.ChildElements.Count - 2;
            HtmlTag startTag = null;
            while (startTagIdex >= 0)
            {
                var tmp = parent.ChildElements[startTagIdex] as HtmlTag;
                if (tmp != null && !tmp.Closed && tmp.EndTag == null && tmp.Name.Equals(tagName, StringComparison.InvariantCultureIgnoreCase))
                {
                    startTag = tmp;
                    break;
                }
                startTagIdex--;
            }
            if (startTag != null)
            {
                startTag.EndTag = (HtmlEndTag) element;
                ((HtmlEndTag) element).StartTag = startTag;
                int rangeStart = startTagIdex + 1;
                int rangeCount = parent.ChildElements.Count - startTagIdex - 2;
                startTag.AssignChildElements(parent.ChildElements.GetRange(rangeStart, rangeCount));
                parent.ChildElements.RemoveRange(rangeStart, rangeCount);
            }
        }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:53,代码来源:HtmlElement.cs

示例5: HtmlContent

 public HtmlContent(Token token)
 {
     Value = token.ReadUntil('<').Trim();
 }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:4,代码来源:HtmlContent.cs

示例6: HtmlComment

 public HtmlComment(Token token)
 {
     token.Skip("<!--");
     Value = token.ReadUntil("-->").Trim();
     token.Skip("-->");
 }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:6,代码来源:HtmlComment.cs

示例7: HtmlEndTag

 public HtmlEndTag(Token token)
 {
     token.MovePast("</");
     TagName = token.ReadUntil(">").ToLower();
     token.MovePast(">");
 }
开发者ID:jeppe-andreasen,项目名称:LinqIt-Libraries,代码行数:6,代码来源:HtmlEndTag.cs


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