本文整理汇总了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("}");
}
示例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(">");
}
示例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;
}
}
}
示例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);
}
}
示例5: HtmlContent
public HtmlContent(Token token)
{
Value = token.ReadUntil('<').Trim();
}
示例6: HtmlComment
public HtmlComment(Token token)
{
token.Skip("<!--");
Value = token.ReadUntil("-->").Trim();
token.Skip("-->");
}
示例7: HtmlEndTag
public HtmlEndTag(Token token)
{
token.MovePast("</");
TagName = token.ReadUntil(">").ToLower();
token.MovePast(">");
}