コード例 #1
0
 public static bool IsValid(this IValidable obj)
 {
     try
     {
         obj.Validate();
         return(true);
     }
     catch { return(false); }
 }
コード例 #2
0
 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);
         }
     }
 }