Example #1
0
        public static ValidationContext InitContext(
            ValidationContext context,
            object obj,
            PropertyDescriptor pd,
            ValidationContext.IsNullHandler isNull)
        {
            if (context == null)
            {
                context = new ValidationContext();
            }

            context.Object             = obj;
            context.IsNull             = isNull ?? new ValidationContext.IsNullHandler(IsNullInternal);
            context.PropertyDescriptor = pd;

            return(context);
        }
Example #2
0
 public static void Validate(object obj, ValidationContext.IsNullHandler isNull)
 {
     Validate(InitContext(null, obj, null, isNull));
 }
Example #3
0
 public static string[] GetErrorMessages(object obj, PropertyDescriptor pd, ValidationContext.IsNullHandler isNull)
 {
     return(GetErrorMessages(InitContext(null, obj, pd, isNull), pd.Name));
 }
Example #4
0
 public static string[] GetErrorMessages(
     object obj, string fieldName, ValidationContext.IsNullHandler isNull)
 {
     return(GetErrorMessages(InitContext(null, obj, null, isNull), fieldName));
 }
Example #5
0
 public static bool IsValid(object obj, PropertyDescriptor pd, ValidationContext.IsNullHandler isNull)
 {
     return(IsValid(InitContext(null, obj, pd, isNull), pd.Name));
 }
Example #6
0
 public static bool IsValid(object obj, string fieldName, ValidationContext.IsNullHandler isNull)
 {
     return(IsValid(InitContext(null, obj, null, isNull), fieldName));
 }