コード例 #1
0
        /// <summary>
        /// Create a friendly error message.
        /// </summary>
        public String ToFriendlyErrorMessage()
        {
            String errorMessage;

            if (this.ErrorMessage.Contains("not recognized as a valid DateTime"))
            {
                errorMessage = "date is not a valid format";
            }
            else if (this.ErrorMessage.Contains("not in a correct format."))
            {
                errorMessage = "entered value is not the correct data type";

                //TODO - developers - add more ElseIf tests here if required to return back the best message possible without using the default
            }
            else
            {
                errorMessage = this.ErrorMessage;
            }

            var propertyName = CamelCaseString.GetWords(this.PropertyName.Contains(".") ? this.PropertyName.Substring(this.PropertyName.LastIndexOf(".") + 1) : this.PropertyName);

            return(string.Concat(propertyName, Constants.StringWhiteSpace, errorMessage));
        }
コード例 #2
0
 /// <summary>
 /// Create an error message with properties separated by white space
 /// </summary>
 public String ToErrorMessage()
 {
     return(String.Concat(CamelCaseString.GetWords(this.PropertyName), Constants.StringWhiteSpace, this.ErrorMessage));
 }