Пример #1
0
        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();
            }
        }
Пример #2
0
        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();
            }
        }
Пример #3
0
 public string GenerateErrorMessage(ErrorMessageFormatOptions errorMessageFormatOptions)
 {
     return(GenerateErrorMessage(errorMessageFormatOptions, false));
 }