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


C# ParserContext.SkipOne方法代码示例

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


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

示例1: HandleInParameter

		/// <summary>
		/// Handles the next character while inside a parameter.
		/// </summary>
		/// <param name="context">The current parsing context.</param>
		private static void HandleInParameter(ParserContext context)
		{
			if (context.IsMasked)
			{
				// All characters allowed
				if (context.CurrentCharacter == '\'')
				{
					if (context.IsNextCharQuote())
					{
						// Masked ', so skip next character and continue
						context.AppendParameter();
						context.SkipOne();
					}
					else
					{
						// End of masked parameter
						context.LogicalPosition = ConstraintPosition.AfterParameter;
						context.AddParameter();
					}
				}
				else
				{
					// All characters allowed
					context.AppendParameter();
				}
			}
			else
			{
				switch (context.CurrentCharacter)
				{
					case ' ': // Space after parameter is allowed
						context.LogicalPosition = ConstraintPosition.AfterParameter;
						if (context.CurrentParameter.Length > 0)
							context.AddParameter();
						break;
					case ',': // End of parameter
						context.LogicalPosition = ConstraintPosition.InParameters;
						if (context.CurrentParameter.Length > 0)
							context.AddParameter();
						break;
					case ')': // At end of parameters
						context.LogicalPosition = ConstraintPosition.AfterParameters;
						if (context.CurrentParameter.Length > 0)
							context.AddParameter();
						break;
					case '[':
					case ']':
					case '(':
					case '\'': // Invalid delimiters without masking
						throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_HandleInParameter_ParamUnmaskedChar), string.Format(Properties.Resources.ConstraintParser_Parse_UnmaskedChar, context.CurrentCharacter), context.StringPosition);
					default: // All other characters allowed in parameter
						context.AppendParameter();
						break;

				}
			}

		}
开发者ID:NerdyDuck,项目名称:NerdyDuck.ParameterValidation,代码行数:62,代码来源:ConstraintParser.cs


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