示例#1
0
 public static bool IsValid(this IValidable obj)
 {
     try
     {
         obj.Validate();
         return(true);
     }
     catch { return(false); }
 }
 private void ValidateAll(object o)
 {
     foreach (FieldInfo fieldInfo in o.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
     {
         IValidable current = fieldInfo.GetValue(o) as IValidable;
         if (current != null)
         {
             current.Validate();
             ValidateAll(current);
         }
     }
 }