本文整理汇总了C#中Scanner.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# Scanner.MoveNext方法的具体用法?C# Scanner.MoveNext怎么用?C# Scanner.MoveNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.MoveNext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
internal static RequestSignature Parse(string signature)
{
var scanner = new Scanner(signature);
var builder = ImmutableArray.CreateBuilder<Token>();
Token token;
do
{
scanner.MoveNext();
token = scanner.CurrentToken;
builder.Add(token);
} while (token.Kind != TokenKind.End);
var parser = new MemberSignatureParser(builder.ToImmutable());
try
{
return parser.Parse();
}
catch (InvalidSignatureException)
{
return null;
}
}
示例2: AssertSequenceOfTokensFrom
private void AssertSequenceOfTokensFrom(Scanner scanner, params Token[] tokens)
{
var tokenNumber = 1;
foreach (var expected in tokens)
{
Assert.True(scanner.MoveNext(), "Missing token number {0}", tokenNumber);
AssertToken(expected, scanner.Current, tokenNumber);
tokenNumber++;
}
Assert.False(scanner.MoveNext(), "Found extra tokens");
}
示例3: AssertHasNext
private void AssertHasNext(Scanner scanner)
{
Assert.True(scanner.MoveNext());
}
示例4: AssertDoesNotHaveNext
private void AssertDoesNotHaveNext(Scanner scanner)
{
Assert.False(scanner.MoveNext());
}
示例5: GetClassificationSpans
/// <summary>
/// This method scans the given SnapshotSpan for potential matches for this classification.
/// In this instance, it classifies everything and returns each span as a new ClassificationSpan.
/// </summary>
/// <param name="trackingSpan">The span currently being classified</param>
/// <returns>A list of ClassificationSpans that represent spans identified to be of this classification</returns>
public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
var classifications = new List<ClassificationSpan>();
var text = span.GetText();
var commentIndex = text.IndexOf('#');
if (commentIndex >= 0)
{
classifications.Add(
new ClassificationSpan(
new SnapshotSpan(
span.Snapshot,
new Span(span.Start + commentIndex, span.Length - commentIndex)
),
_comment
)
);
text = text.Substring(0, commentIndex);
}
var match = Regex.Match(text, @"^( *(\t+))+");
if (match.Success)
{
foreach (Capture capture in match.Groups[2].Captures)
{
classifications.Add(
new ClassificationSpan(
new SnapshotSpan(
span.Snapshot,
new Span(span.Start + capture.Index, capture.Length)
),
_tab
)
);
}
}
try
{
var scanner = new Scanner(new StringReader(text));
Type previousTokenType = null;
while (scanner.MoveNext())
{
IClassificationType classificationType = null;
var currentTokenType = scanner.Current.GetType();
var tokenLength = scanner.Current.End.Index - scanner.Current.Start.Index;
if (currentTokenType == typeof(Anchor))
{
classificationType = _anchor;
}
else if (currentTokenType == typeof(AnchorAlias))
{
classificationType = _alias;
}
else if (currentTokenType == typeof(Scalar))
{
if (previousTokenType == typeof (Key))
{
classificationType = _key;
}
else
{
// Decode the scalar
var scalarToken = (Scalar) scanner.Current;
var scalar = new Core.Yaml.Events.Scalar(scalarToken.Value);
switch (schema.GetDefaultTag(scalar))
{
case JsonSchema.BoolShortTag:
classificationType = _bool;
break;
case JsonSchema.FloatShortTag:
case JsonSchema.IntShortTag:
classificationType = _number;
break;
case SchemaBase.StrShortTag:
classificationType = scalarToken.Style == ScalarStyle.DoubleQuoted || scalarToken.Style == ScalarStyle.SingleQuoted ? _string : _value;
break;
default:
classificationType = _value;
break;
}
}
}
else if (currentTokenType == typeof(Tag))
{
classificationType = _tag;
}
else if (currentTokenType == typeof(TagDirective))
//.........这里部分代码省略.........