Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting method in sub class
Message
De
24/03/2015 14:51:45
 
 
À
24/03/2015 12:56:38
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
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:
01617215
Vues:
33
>>TBH I don't know why Michel has implemented it this way. If a parent class has a default method I would assume that that should be used unless overridden.
>>And if it is not a virtual method on the base class then defining an interface for the method would make it easier (and faster) to check.
>>Perhaps Michel will give us more of an insight into this ?
>
>The framework class has it like this:
>
>
>    Public Overridable Function InitializeWithRow() As Boolean
>        Return True
>    End Function
>
>
>The client class, optionally, can use it if necessary like this:
>
>
>    Public Overrides Function InitializeWithRow() As Boolean
>
>        ' Put something in here
>
>        Return True
>    End Function
>
>
>In that particular framework overridable method design, if the DataEntry framework class has a primary key, I need to validate a few things in the framework class before allowing the call to the cilent class. So, this goes like this:
>
>
>        ' The following could be a simple call to InitializeWithRow() as this is an overridable method. However,
>        ' because InitializeWithRow() should be used only when we have a primary, thus oRow would be available,
>        ' we are using it like that to verify first if the method exists in the client class. If yes, we verify
>        ' first to see if we have a primary key. If yes, we continue with the call to the method. Otherwise,
>        ' we redirect the user to the domain as this means the user manipulated the URL by removing the Session
>        ' or the primary key.
>
>        ' If the method exists in the client class
>        If loReflection.IsMethodExistInSubClass(Me, "InitializeWithRow") Then
>
>            ' If we have a primary key
>            If nPrimaryKey > 0 Then
>
>                ' Initialization code with row
>                If Not InitializeWithRow() Then
>                    Return False
>                End If
>
>            Else
>
>                ' If the primary key is mandatory
>                If lPrimaryKeyIsMandatory Then
>
>                    ' If we are using an ID on entry to locate a record on the table but we are adding
>                    If lSwitchFromUpdateToAdd Then
>                    Else
>                        oProcess.RedirectMain(oProcess.cHttp)
>                    End If
>
>                End If
>
>            End If
>
>        End If
>
So when do you use the parent class implementation ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform