Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Validating on Overridable method
Message
De
05/09/2011 15:20:47
 
 
À
05/09/2011 15:17:07
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01522449
Message ID:
01522756
Vues:
20
>The class from which all other .NET reference types are derived. If you simply declare a class without specifying a base class then it derives from System.Object.

Ok, I tried to incorporate this into the method. For now, it looks like this:
        ' 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 loTypeParent 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)

            ' Get a reference to the same object as well so we can climb up the chain for comparism
            loTypeParent = loType

            ' Loop until we have reached the base class
            While True

                ' If we have reached the base class
                If loTypeParent.BaseType = loType.BaseType Then
                    Exit While
                Else
                    loTypeParent = loTypeParent.BaseType
                End If

            End While

            ' Get the base class name
            lcBaseClass = loTypeParent.Name

            ' If the method exists in the sub class
            If loMethodInfo.DeclaringType.Name <> lcBaseClass Then
                llExist = True
            End If

            Return llExist
        End Function
But, that doesn't work anymore to recognize the overridable method. It is something in the While loop that I need to adjust.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform