public bool ValidateProperties() { var propertiesWithChangedErrors = new List <string>(); // Get all the properties decorated with the ValidationAttribute attribute. if (PropertyInfos != null) { foreach (PropertyInfo propertyInfo in PropertyInfos) { var propertyErrors = new List <string>(); TryValidateProperty(propertyInfo, propertyErrors); // If the errors have changed, save the property name to notify the update at the end of this method. ErrorsContainer.SetErrors(propertyInfo.Name, propertyErrors); } } var propertiesToValidate = this.GetType() .GetRuntimeProperties() .Where(c => c.GetCustomAttributes(typeof(ValidationAttribute)).Any()); foreach (PropertyInfo propertyInfo in propertiesToValidate) { var propertyErrors = new List <string>(); TryValidateProperty(propertyInfo, propertyErrors); // If the errors have changed, save the property name to notify the update at the end of this method. ErrorsContainer.SetErrors(propertyInfo.Name, propertyErrors); } return(ErrorsContainer.HasErrors); }
public Dictionary <string, List <string> > GetAllErrors() { return(ErrorsContainer.GetAllErrors()); }
public void SetErrors <TProperty>(Expression <Func <TProperty> > propertyExpression, IEnumerable <string> errors) { ErrorsContainer.SetErrors(propertyExpression, errors); }
public IEnumerable GetErrors(string propertyName) { return(ErrorsContainer.GetErrors(propertyName)); }