本文整理汇总了C#中Token.Peeks方法的典型用法代码示例。如果您正苦于以下问题:C# Token.Peeks方法的具体用法?C# Token.Peeks怎么用?C# Token.Peeks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.Peeks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static new JSONString Parse(Token token)
{
StringBuilder builder = new StringBuilder();
token.MoveToContent();
if (!token.Peeks("\""))
{
return null;
}
token.MovePast("\"");
while (!token.Peeks("\""))
{
if (token.Peeks("\\\""))
{
builder.Append("\"");
token.Skip(2);
}
else
{
builder.Append(token.Current);
token.Skip(1);
}
}
token.MovePast("\"");
return new JSONString(builder.ToString());
}
示例2: Parse
public static new JSONBoolean Parse(Token token)
{
token.MoveToContent();
if (token.Peeks("true"))
{
token.Skip("true");
return new JSONBoolean(true);
}
if (token.Peeks("false"))
{
token.Skip("false");
return new JSONBoolean(false);
}
return null;
}
示例3: Parse
// Methods
public static new JSONNull Parse(Token token)
{
token.MoveToContent();
if (token.Peeks("null"))
{
token.Skip(4);
return JSONValue.Null;
}
return null;
}
示例4: 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(">");
}
示例5: 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;
}
}
}
示例6: 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);
}
}