/// <summary> /// 验证特性 /// </summary> /// <param name="property"> /// The property. /// </param> /// <param name="attribute"> /// The attribute. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> private bool ValidateAttribute(PropertyInfo property, ValidationAttribute attribute) { var isValid = attribute.IsValid(property.GetValue(_target)); if (isValid) { return true; } _result.Add(new ValidationResult(GetErrorMessage(attribute))); return false; }
/// <summary> /// 验证特性 /// </summary> private void ValidateAttribute( PropertyInfo property, ValidationAttribute attribute ) { bool isValid = attribute.IsValid( property.GetValue( _target ) ); if( isValid ) return; _result.Add( new ValidationResult( GetErrorMessage( attribute ) ) ); }