本文整理汇总了C#中ParseState.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ParseState.ToString方法的具体用法?C# ParseState.ToString怎么用?C# ParseState.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseState
的用法示例。
在下文中一共展示了ParseState.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseNonStateChange
private static void ParseNonStateChange(BreakingChange currentBreak, ParseState state, string currentLine, IEnumerable<string> allowedCategories)
{
switch (state)
{
case ParseState.None:
return;
case ParseState.OriginalBug:
currentBreak.BugLink = currentLine.Trim();
break;
case ParseState.Scope:
BreakingChangeImpact scope;
if (Enum.TryParse<BreakingChangeImpact>(currentLine.Trim(), out scope))
{
currentBreak.ImpactScope = scope;
}
break;
case ParseState.VersionBroken:
Version verBroken;
if (Version.TryParse(currentLine.Trim(), out verBroken))
{
currentBreak.VersionBroken = verBroken;
}
break;
case ParseState.VersionFixed:
Version verFixed;
if (Version.TryParse(currentLine.Trim(), out verFixed))
{
currentBreak.VersionFixed = verFixed;
}
break;
case ParseState.AffectedAPIs:
// Trim md list and code markers, as well as comment tags (in case the affected APIs section is followed by a comment)
string api = currentLine.Trim().TrimStart('*', '-', '`', ' ', '\t', '<', '!', '-').TrimEnd('`');
if (string.IsNullOrWhiteSpace(api)) return;
if (currentBreak.ApplicableApis == null)
{
currentBreak.ApplicableApis = new List<string>();
}
currentBreak.ApplicableApis.Add(api);
break;
case ParseState.Details:
if (currentBreak.Details == null)
{
currentBreak.Details = currentLine;
}
else
{
currentBreak.Details += ("\n" + currentLine);
}
break;
case ParseState.Suggestion:
if (currentBreak.Suggestion == null)
{
currentBreak.Suggestion = currentLine;
}
else
{
currentBreak.Suggestion += ("\n" + currentLine);
}
break;
case ParseState.Notes:
// Special-case the fact that 'notes' will often come at the end of a comment section and we don't need the closing --> in the note.
if (currentLine.Trim().Equals("-->")) return;
if (currentBreak.Notes == null)
{
currentBreak.Notes = currentLine;
}
else
{
currentBreak.Notes += ("\n" + currentLine);
}
break;
case ParseState.SourceAnalyzerStatus:
BreakingChangeAnalyzerStatus status;
if (Enum.TryParse<BreakingChangeAnalyzerStatus>(currentLine.Trim().Replace(" ", ""), true, out status))
{
currentBreak.SourceAnalyzerStatus = status;
}
break;
case ParseState.Categories:
// Trim md list and code markers, as well as comment tags (in case the categories section is followed by a comment)
var category = currentLine.Trim().TrimStart('*', '-', '!', '<', '>');
if (string.IsNullOrWhiteSpace(category)) break;
if (currentBreak.Categories == null)
{
currentBreak.Categories = new List<string>();
}
// If a list of allowed categories was provided, make sure that the category found is on the list
if (!allowedCategories?.Contains(category, StringComparer.OrdinalIgnoreCase) ?? false)
{
throw new InvalidOperationException($"Invalid category detected: {category}");
}
currentBreak.Categories.Add(category);
break;
default:
throw new InvalidOperationException("Unhandled breaking change parse state: " + state.ToString());
}
}
示例2: ParseNonStateChange
private static void ParseNonStateChange(BreakingChange currentBreak, ParseState state, string currentLine)
{
switch (state)
{
case ParseState.None:
return;
case ParseState.OriginalBug:
currentBreak.BugLink = currentLine.Trim();
break;
case ParseState.Scope:
BreakingChangeImpact scope;
if (Enum.TryParse<BreakingChangeImpact>(currentLine.Trim(), out scope))
{
currentBreak.ImpactScope = scope;
}
break;
case ParseState.VersionBroken:
Version verBroken;
if (Version.TryParse(currentLine.Trim(), out verBroken))
{
currentBreak.VersionBroken = verBroken;
}
break;
case ParseState.VersionFixed:
Version verFixed;
if (Version.TryParse(currentLine.Trim(), out verFixed))
{
currentBreak.VersionFixed = verFixed;
}
break;
case ParseState.AffectedAPIs:
// Trim md list markers, as well as comment tags (in case the affected APIs section is followed by a comment)
string api = currentLine.Trim().TrimStart('*', '-', ' ', '\t', '<', '!', '-');
if (string.IsNullOrWhiteSpace(api)) return;
if (currentBreak.ApplicableApis == null)
{
currentBreak.ApplicableApis = new List<string>();
}
((List<string>)currentBreak.ApplicableApis).Add(api);
break;
case ParseState.Details:
if (currentBreak.Details == null)
{
currentBreak.Details = currentLine;
}
else
{
currentBreak.Details += ("\n" + currentLine);
}
break;
case ParseState.Suggestion:
if (currentBreak.Suggestion == null)
{
currentBreak.Suggestion = currentLine;
}
else
{
currentBreak.Suggestion += ("\n" + currentLine);
}
break;
case ParseState.Notes:
// Special-case the fact that 'notes' will often come at the end of a comment section and we don't need the closing --> in the note.
if (currentLine.Trim().Equals("-->")) return;
if (currentBreak.Notes == null)
{
currentBreak.Notes = currentLine;
}
else
{
currentBreak.Notes += ("\n" + currentLine);
}
break;
default:
throw new InvalidOperationException("Unhandled breaking change parse state: " + state.ToString());
}
}