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


C# Scanner.MoveNext方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:21,代码来源:MemberSignatureParser.cs

示例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");
		}
开发者ID:modulexcite,项目名称:SharpYaml,代码行数:11,代码来源:ScannerTests.cs

示例3: AssertHasNext

 private void AssertHasNext(Scanner scanner)
 {
     Assert.True(scanner.MoveNext());
 }
开发者ID:roji,项目名称:YamlDotNet,代码行数:4,代码来源:ScannerTests.cs

示例4: AssertDoesNotHaveNext

 private void AssertDoesNotHaveNext(Scanner scanner)
 {
     Assert.False(scanner.MoveNext());
 }
开发者ID:roji,项目名称:YamlDotNet,代码行数:4,代码来源:ScannerTests.cs

示例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))
//.........这里部分代码省略.........
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:101,代码来源:AssetObjectEditorProvider.cs


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