Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validating on Overridable method
Message
From
05/09/2011 12:31:42
 
 
To
05/09/2011 12:29:56
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01522449
Message ID:
01522738
Views:
26
>>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.

Not so. If this is a derived class then DeclaringType.Name wil be the name of the derived class....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform