GetBusinessRuleWarnings() public méthode

Gets all the business rule warnings.
public GetBusinessRuleWarnings ( ) : List
Résultat List
Exemple #1
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);
        }
Exemple #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)
 {
     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 ReturnsRightValidationsForEmptyContextWithTag()
            {
                var context = new ValidationContext();

                var businessRuleValidations = context.GetBusinessRuleWarnings("tag");
                Assert.AreEqual(0, businessRuleValidations.Count);
            }