' If a method exists in a sub class ' expO1 Originator ' expC1 Name of the method ' expC2 Name of the base class Public Function IsMethodExistInSubClass(ByVal toOriginator As Object, ByVal tcMethod As String, _ ByVal tcBaseClass As String) As Boolean Dim llExist As Boolean = False Dim loType 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 method loMethodInfo = loType.GetMethod(tcMethod, System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.Public) ' If the method exists in the client class If loMethodInfo.DeclaringType.Name <> tcBaseClass Then llExist = True End If Return llExist End FunctionIn my DataEntry class, I added this:
Dim loReflection As Framework.Reflection = New Framework.Reflection(oProcess) ' If the method exists in the client class If loReflection.IsMethodExistInSubClass(Me, "InitializeWithRow", "DataEntry") Then ' Just in case the user manipulated the URL If nPrimaryKey = 0 Then oProcess.oResponse.Redirect("Default.aspx") End If End IfNow, in this design, I am passing a 3rd parameter which represents the name of the baseclass. I was wondering if from the Reflection class, I can detect that automatically, thus making it only to have to pass two parameters, the object itself of the class and the name of the overridable method I would like to check for.