public string GenerateErrorMessage(ErrorMessageFormatOptions errorMessageFormatOptions, bool useBullets) { if (this._PropertyErrors.Count == 0) { return(null); } StringBuilder sb = new StringBuilder(); string prefix = useBullets ? "\u2022 " : string.Empty; switch (errorMessageFormatOptions) { case ErrorMessageFormatOptions.ShowAll: foreach (string text in this._PropertyErrors.Values.Select(c => c.ErrorMessage)) { sb.AppendLine(prefix + text); } return(sb.ToString()); case ErrorMessageFormatOptions.ShowDistinct: foreach (string text in new HashSet <string>(this._PropertyErrors.Values.Select(c => c.ErrorMessage))) { sb.AppendLine(prefix + text); } return(sb.ToString()); default: throw new NotImplementedException(); } }
public IEnumerable <string> GetIndividualErrorMessages(ErrorMessageFormatOptions errorMessageFormatOptions) { switch (errorMessageFormatOptions) { case ErrorMessageFormatOptions.ShowAll: foreach (string text in this._PropertyErrors.Values.Select(c => c.ErrorMessage)) { yield return(text); } yield break; case ErrorMessageFormatOptions.ShowDistinct: foreach (string text in new HashSet <string>(this._PropertyErrors.Values.Select(c => c.ErrorMessage))) { yield return(text); } yield break; default: throw new NotImplementedException(); } }
public string GenerateErrorMessage(ErrorMessageFormatOptions errorMessageFormatOptions) { return(GenerateErrorMessage(errorMessageFormatOptions, false)); }