' If a method exists in a sub class ' expO1 Originator ' expC1 Name of the method Public Function IsMethodExistInSubClass(ByVal toOriginator As Object, ByVal tcMethod As String) As Boolean Dim lcBaseClass As String = "" Dim llExist As Boolean = False Dim loType As Type = Nothing Dim loTypeBaseClass As Type = Nothing Dim loMethodInfo As System.Reflection.MethodInfo = Nothing ' Get a reference to the originator type loType = toOriginator.GetType() ' Get a reference to the base class loTypeBaseClass = loType.BaseType ' Get a reference to the method loMethodInfo = loType.GetMethod(tcMethod, System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.Public) ' Get the base class name lcBaseClass = loTypeBaseClass.Name ' If the method exists in the client class If loMethodInfo.DeclaringType.Name <> lcBaseClass Then llExist = True End If Return llExist End FunctionAnd, from the base class:
Dim loReflection As Framework.Reflection = New Framework.Reflection(oProcess) ' If the method exists in the client class If loReflection.IsMethodExistInSubClass(Me, "InitializeWithRow") Then ' Just in case the user manipulated the URL If nPrimaryKey = 0 Then oProcess.oResponse.Redirect("Default.aspx") End If End If