Catel.Data.ValidationContext.GetFieldErrors C# (CSharp) Метод

GetFieldErrors() публичный Метод

Gets all the field errors for the specified property name.
The is null or whitespace.
public GetFieldErrors ( string propertyName ) : List
propertyName string Name of the property.
Результат List
        public List<IFieldValidationResult> GetFieldErrors(string propertyName)
        {
            Argument.IsNotNullOrWhitespace("propertyName", propertyName);

            lock (_fieldValidations)
            {
                var list = (from validation in _fieldValidations
                            where string.Equals(validation.PropertyName, propertyName, StringComparison.OrdinalIgnoreCase) &&
                                  validation.ValidationResultType == ValidationResultType.Error
                            select validation).ToList();

                return list;
            }
        }

Same methods

ValidationContext::GetFieldErrors ( ) : List
ValidationContext::GetFieldErrors ( object tag ) : List
ValidationContext::GetFieldErrors ( string propertyName, object tag ) : List

Usage Example

Пример #1
0
        /// <summary>
        /// Gets the validation errors for a specified property or for the entire object.
        /// </summary>
        /// <param name="propertyName">The name of the property to retrieve validation errors for, or null or <see cref="F:System.String.Empty"/> to retrieve errors for the entire object.</param>
        /// <returns>
        /// The validation errors for the property or object.
        /// </returns>
        IEnumerable INotifyDataErrorInfo.GetErrors(string propertyName)
        {
            if (HideValidationResults)
            {
                yield return(null);
            }

            if (string.IsNullOrEmpty(propertyName))
            {
                lock (ValidationContext)
                {
                    foreach (var error in ValidationContext.GetBusinessRuleErrors())
                    {
                        yield return(error.Message);
                    }
                }
            }
            else
            {
                lock (ValidationContext)
                {
                    foreach (var error in ValidationContext.GetFieldErrors(propertyName))
                    {
                        yield return(error.Message);
                    }
                }
            }
        }
All Usage Examples Of Catel.Data.ValidationContext::GetFieldErrors