Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Validating on Overridable method
Message
De
05/09/2011 12:29:56
 
 
À
03/09/2011 03:41:41
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:
01522736
Vues:
23
>You could use Reflection. Simplified example:
Public Class BaseClass
>	Public Function DataEntry() As Boolean
>		Dim t As Type = Me.[GetType]()
>		Dim minfo As MethodInfo = t.GetMethod("InitializeWithRow", BindingFlags.Instance Or BindingFlags.[Public])
>		If minfo.DeclaringType.Name <> "BaseClass" AndAlso DoCheck() Then
>			Return InitializeWithRow()
>		End If
>		Return True
>	End Function
>
>	Public Overridable Function InitializeWithRow() As Boolean
>		Return True
>	End Function
>
>	Public Function DoCheck() As Boolean
>		'Decide whether to call InitializeWithRow()
>		Return True
>	End Function
>End Class
(Syntax not checked)

minfo.DeclaringType.Name will always be equal to the base class name. So, something has to be adjusted in there.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform