Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting method in sub class
Message
De
23/03/2015 15:15:45
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Detecting method in sub class
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01617154
Message ID:
01617154
Vues:
50
I have this code in my main class:
        ' If the method exists in the client class
        If loReflection.IsMethodExistInSubClass(Me, "InitializeWithRow") Then

        End If
The Reflection method is as follow:
    ' 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 Is Nothing Then
            Return False
        End If

        ' Loop until we have reached the base class
        While loType <> GetType(Object)
            loType = loType.BaseType
        End While

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

        Return llExist
    End Function
I just found out that this no longer works. In my client class, I do not override the InitializeWithRow() method. However, it goes in the condition.

Anyone would know what is failing?
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform