> ' 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 Function >>
> 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 If >>
loType.BaseType.NameUntested. And it only gives the immediate parent - if the actual class has a deeper hierarchy it won't work.....