ValidateHandler

ValidateHandler

Old forum URL: forums.lhotka.net/forums/t/2218.aspx


JoeFallon1 posted on Saturday, January 27, 2007

The ValidateHandler() method performs a check to ensure that the rule method is not an instance method of the business object type:

Private Function ValidateHandler(ByVal method As System.Reflection.MethodInfo) As Boolean
  If Not method.IsStatic AndAlso method.DeclaringType.Equals(mTarget.GetType) Then
    Throw New InvalidOperationException(String.Format("{0}: {1}", _   My.Resources.InvalidRuleMethodException, method.Name))
  End If

  Return True
End Function

Question:

What if you have split classes and the Base type has an instance method which is inherited by the final type? Will this code catch that? Should it?

Joe

 

xal replied on Saturday, January 27, 2007

No, you're right, I don't think it will catch that, and it should.
Although it is unlikely that anyone will create an instance rule method in a base class and add it in the derived class, it certainly is possible.

Andrés

Copyright (c) Marimer LLC