Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting method in sub class
Message
From
24/03/2015 12:07:26
 
 
To
24/03/2015 09:29:30
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01617154
Message ID:
01617199
Views:
33
>>If I understand correctly you are just trying to determine whether the method is overridden in the child class. If so I don't know why you are walking the class hierarchy. If the method exists then you could just use :
return (loMethodInfo.ReflectedType = loMethodInfo.DeclaringType)
>
>This works. Thanks
>
>Is this how you see this:
>
>
>    ' If a method exists in a sub class. This is used when we negotiate with the Overrides method. Thus, the framework
>    ' may know if the Overrides method exists in the sub class. This is used in the DataEntry class. So, if the method
>    ' does not exist, we do not call it. And, if it exists, it allows us to validate, if necessary, before proceeding.
>    ' expO1 Originator
>    ' expC1 Name of the method
>    Public Function IsMethodExistInSubClass(ByVal toOriginator As Object, ByVal tcMethod 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 does not exist
>        If loMethodInfo.ReflectedType = loMethodInfo.DeclaringType Then
>            llExist = True
>        End If
>
>        Return llExist
>    End Function
>
Essentially yes - but could be simplified:
Dim loMethodInfo = toOriginator.GetMethod(tcMethod, System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.Public)

return (loMethodInfo IsNot Nothing AndAlso loMethodInfo.ReflectedType = loMethodInfo.DeclaringType)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform