Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Design issues
Message
From
05/08/2010 02:03:36
 
 
To
04/08/2010 22:19:50
General information
Forum:
ASP.NET
Category:
Class design
Title:
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01475236
Message ID:
01475245
Views:
95
This message has been marked as the solution to the initial question of the thread.
Hi Michel,
I don't know am I correct understand the problem ;)) but when so..
So far as I understand, baseclass logic not using in private case, and you want to put logic in current case to client class.
I did it this way

For Example

Public Class Parser
    Public Class Parser
      Public Event OnReplaceWithThisContent(ByVal e as MyEventArgs)

       Public Overridable Function ReplaceWithThisContent() As Boolean
           Dim loMyEventArg as MyEventArgs = new MyEventArgs
           RaiseEvent OnReplaceWithThisContent(loMyEventArg)
           IF  loMyEventArg.pmks_nodefault = true
                Return(loMyEventArg.pmks_returnvalue)
           Else
           Return True
           End if
       End Function

    End Class

    Public Class myEventArgs 
           pmks_nodefault = false
           pmks_returnvalue as Object = false
    End Class
Step 2.
Replace the logic to client side
Public Class ViewPagePage

    Inherits Framework.Framework.ViewPage

    Public Overrides Function GetPage() As Boolean
        Dim loParser As Framework.Framework.Parser = New Framework.Framework.Parser(oProcess)
        AddHandler loParser.OnReplaceWithThisContent, AddressOf MyOnReplaceWithThisContent
        ' Parse for table
        loParser.cTable = "Company"
        loParser.cContent = lcNotes
        loParser.oOriginator = Me
        If Not loParser.ParseForTable() Then
            Return False
        End If

        Return True
    End Function

   Private Sub MyOnReplaceWithThisContent(ByVal e as MyEventArgs)
    e.pmks_nodefault = true
    e.pmks_returnvalue = false
   End Sub
In This case.. when you run loParser.ParseForTable - at first it RaiseEvent OnReplaceWithThisContent with
argument MyEventArgs.
Because MyEventArgs sends by reference, we can set e.pmks_nodefault (which will stop standard behaviour of method) and move all logic to MyOnReplaceWithThisContent.. where set neccessary Return Value.


I hope it help, when I understand task correct ;)

Denis





>Usually, when I want to define a method overridable in a class, I do it like this:
>
>
>    Public Class Parser
>
>        Public Overridable Function ReplaceWithThisContent() As Boolean
>            Return True
>        End Function
>
>    End Class
>
>
>So, basically, in the client, I can define this overridable method like this:
>
>
>        Public Overrides Function ReplaceWithThisContent() As Boolean
>            Return True
>        End Function
>
>
>This works for a long as the client is inheriting from the class.
>
>However, in one particular class, which is already inheriting from something else, I need to create an object from Parser class. This works. So, in the client, I may have something like this:
>
>
>Public Class ViewPagePage
>
>    Inherits Framework.Framework.ViewPage
>
>    Public Overrides Function GetPage() As Boolean
>        Dim loParser As Framework.Framework.Parser = New Framework.Framework.Parser(oProcess)
>
>        ' Parse for table
>        loParser.cTable = "Company"
>        loParser.cContent = lcNotes
>        loParser.oOriginator = Me
>        If Not loParser.ParseForTable() Then
>            Return False
>        End If
>
>        Return True
>    End Function
>
>
>However, because the client is not inheriting from the Parser class, I cannot benefit from its Overridable ReplaceWithThisContent() method.
>
>Because, in the Parser.ParseForTable() method, I need to call a method in the client for every record of a loop which is being processed at the class level. So, basically, the class handles all the logistic but for every record it processes, some sub logic is custom to each client. This works ok on all other places I have something like this because the client is always inheriting from the class itself. But, in this case, the client is already inheriting from another class. So, I am losing the capability of using the overridable method. Any idea?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform