private static string FailuresToFailureString(IImmutableList <Failure> failures) { ErrorRelevanceConfidence maxConfidence = failures.Max(failure => failure.Relevance); IEnumerable <string> relevantFailureTexts = failures .Where(f => f.Relevance == maxConfidence) .Select(f => f.Error) .Distinct(); return(string.Join(", or ", relevantFailureTexts)); }
public Failure(ErrorRelevanceConfidence relevance, string error) { Relevance = relevance; Error = error; }
/// <summary> /// Create an unsuccessful parse result object, without any nested failure. /// </summary> /// <param name="message">A message describing the error.</param> /// <param name="relevance">(optional) How likely it is that this error is relevant to the overall parsing, /// or in other words how useful it will probably be if reported to the user.</param> /// <returns>An respective instance of <see cref="ArgsParseResult{T}"/></returns> public static ArgsParseResult <T> Failure( string message, ErrorRelevanceConfidence relevance = ErrorRelevanceConfidence.Default) { return(new ArgsParseResult <T>(null, ImmutableList.Create(new Failure(relevance, message)))); }