Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
 /// <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 ) ) ); 
 }