本文整理汇总了C#中ParserContext.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# ParserContext.MoveNext方法的具体用法?C# ParserContext.MoveNext怎么用?C# ParserContext.MoveNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserContext
的用法示例。
在下文中一共展示了ParserContext.MoveNext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parses a string containing the textual representation of one or more <see cref="Constraints"/>.
/// </summary>
/// <param name="constraints">A string containing one or more constraints. May be null or empty.</param>
/// <param name="type">The data type to create specific constraints for.</param>
/// <returns>A collection of <see cref="Constraint"/> instances. If <paramref name="constraints"/> is <see langword="null"/> or empty, an empty list is returned.</returns>
/// <exception cref="CodedArgumentOutOfRangeException"><paramref name="type"/> is <see cref="ParameterDataType.None"/>.</exception>
/// <exception cref="ConstraintParserException"><paramref name="constraints"/> is not a valid constraint string.</exception>
public IReadOnlyList<Constraint> Parse(string constraints, ParameterDataType type)
{
if (type == ParameterDataType.None)
{
throw new CodedArgumentOutOfRangeException(Errors.CreateHResult(ErrorCodes.ConstraintParser_Parse_DataTypeNone), Properties.Resources.Global_ParameterDataType_None);
}
if (string.IsNullOrWhiteSpace(constraints))
return new List<Constraint>();
ParserContext context = new ParserContext(constraints, type);
while (context.MoveNext())
{
switch (context.LogicalPosition)
{
case ConstraintPosition.OutsideConstraint:
HandleOutsideConstraint(context);
break;
case ConstraintPosition.InConstraint:
HandleInConstraint(context);
break;
case ConstraintPosition.InParameters:
HandleInParameters(context);
break;
case ConstraintPosition.InParameter:
HandleInParameter(context);
break;
case ConstraintPosition.AfterParameter:
HandleAfterParameter(context);
break;
case ConstraintPosition.AfterParameters:
HandleAfterParameters(context);
break;
}
}
if (context.LogicalPosition != ConstraintPosition.OutsideConstraint)
{
throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_Parse_IncompleteConstraint), Properties.Resources.ConstraintParser_Parse_ConstraintIncomplete, context.CurrentConstraintStart);
}
return context.Constraints;
}