本文整理汇总了C#中ParserContext.ResetConstraintData方法的典型用法代码示例。如果您正苦于以下问题:C# ParserContext.ResetConstraintData方法的具体用法?C# ParserContext.ResetConstraintData怎么用?C# ParserContext.ResetConstraintData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserContext
的用法示例。
在下文中一共展示了ParserContext.ResetConstraintData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleAfterParameters
/// <summary>
/// Handles the next character while after parameters.
/// </summary>
/// <param name="context">The current parsing context.</param>
private void HandleAfterParameters(ParserContext context)
{
switch (context.CurrentCharacter)
{
case ']': // Constraint end
context.Constraints.Add(CreateConstraint(context));
context.ResetConstraintData();
break;
default: // Invalid char after parameters
throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_HandleAfterParameters_CharAfterParams), string.Format(Properties.Resources.ConstraintParser_Parse_InvalidCharAfterParams, context.CurrentCharacter), context.StringPosition);
}
}
示例2: HandleInConstraint
/// <summary>
/// Handles the next character while inside of a constraint.
/// </summary>
/// <param name="context">The current parsing context.</param>
private void HandleInConstraint(ParserContext context)
{
switch (context.CurrentCharacter)
{
case ' ': // No spaces in names
case '\'': // No quote in names
case '[': // Invalid constraint start in constraint
case ')': // Invalid parameter end in constraint
throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_HandleInConstraint_InvalidChar), string.Format(Properties.Resources.ConstraintParser_Parse_InvalidCharInName, context.CurrentCharacter), context.StringPosition);
case ']': // Constraint without parameters
context.CurrentConstraintStart++;
if (context.StringPosition == context.CurrentConstraintStart)
{
// No constraint name
throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_HandleInConstraint_EmptyConstraint), Properties.Resources.ConstraintParser_Parse_EmptyConstraint, context.StringPosition);
}
context.CurrentConstraintName = context.GetSubstring(context.CurrentConstraintStart, context.StringPosition - context.CurrentConstraintStart);
context.Constraints.Add(CreateConstraint(context));
context.ResetConstraintData();
break;
case '(': // Start of parameters
context.CurrentConstraintStart++;
if (context.StringPosition == context.CurrentConstraintStart)
{
// No constraint name
throw new ConstraintParserException(Errors.CreateHResult(ErrorCodes.ConstraintParser_HandleInConstraint_EmptyConstraint), Properties.Resources.ConstraintParser_Parse_EmptyConstraint, context.StringPosition);
}
context.CurrentConstraintName = context.GetSubstring(context.CurrentConstraintStart, context.StringPosition - context.CurrentConstraintStart);
context.LogicalPosition = ConstraintPosition.InParameters;
break;
}
}