GetFieldWarnings() public method

Gets all the field warnings.
public GetFieldWarnings ( ) : List
return List
Example #1
0
        /// <summary>
        /// Gets a warning for a specific column.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <returns>The warning or <see cref="string.Empty"/> if no warning is available.</returns>
        string IDataWarningInfo.this[string columnName]
        {
            get
            {
                if (string.IsNullOrEmpty(columnName))
                {
                    return(string.Empty);
                }

                if (HideValidationResults)
                {
                    return(string.Empty);
                }

                if (!IsValidated && AutomaticallyValidateOnPropertyChanged)
                {
                    Validate();
                }

                var warning = (from fieldWarning in ValidationContext.GetFieldWarnings(columnName)
                               select fieldWarning.Message).FirstOrDefault();

                return(warning ?? string.Empty);
            }
        }
Example #2
0
        /// <summary>
        /// Gets the warnings for the specific property name.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns><see cref="IEnumerable"/> of warnings.</returns>
        IEnumerable INotifyDataWarningInfo.GetWarnings(string propertyName)
        {
            var elements = new List <string>();

            if (HideValidationResults)
            {
                return(elements);
            }

            if (string.IsNullOrEmpty(propertyName))
            {
                lock (_validationContext)
                {
                    foreach (var warning in _validationContext.GetBusinessRuleWarnings())
                    {
                        elements.Add(warning.Message);
                    }
                }
            }
            else
            {
                lock (_validationContext)
                {
                    foreach (var warning in _validationContext.GetFieldWarnings(propertyName))
                    {
                        elements.Add(warning.Message);
                    }
                }
            }

            return(elements);
        }
Example #3
0
 /// <summary>
 /// Gets the warnings for the specific property name.
 /// </summary>
 /// <param name="propertyName">Name of the property.</param>
 /// <returns><see cref="IEnumerable"/> of warnings.</returns>
 IEnumerable INotifyDataWarningInfo.GetWarnings(string propertyName)
 {
     if (string.IsNullOrEmpty(propertyName))
     {
         lock (ValidationContext)
         {
             foreach (var warning in ValidationContext.GetBusinessRuleWarnings())
             {
                 yield return(warning.Message);
             }
         }
     }
     else
     {
         lock (ValidationContext)
         {
             foreach (var warning in ValidationContext.GetFieldWarnings(propertyName))
             {
                 yield return(warning.Message);
             }
         }
     }
 }
            public void ReturnsRightValidationsForEmptyContextWithTagAndPropertyName()
            {
                var context = new ValidationContext();

                var fieldValidations = context.GetFieldWarnings("MyProperty", "tag");
                Assert.AreEqual(0, fieldValidations.Count);
            }
            public void ReturnsRightValidationsForEmptyContextWithTag()
            {
                var context = new ValidationContext();

                var fieldValidations = context.GetFieldWarnings((object)"tag");
                Assert.AreEqual(0, fieldValidations.Count);
            }