Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Overload design when two different types of object
Message
From
05/09/2006 20:50:35
 
 
To
05/09/2006 19:26:19
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01151161
Message ID:
01151172
Views:
35
Well, depending on which overload you use to instantiate your class, either oApp is Nothing or oProcess is Nothing. So, in your GetSchema method, you could check for that and if oApp is Nothing, use New Framework.Data(oProcess) and vice versa.

~~Bonnie



>Lets say I have a class which contains those two properties:
>
>
>        Private oApp As Framework.App
>        Private oProcess As Framework.LXProcess
>
>
>Then, the New() event supports overload such as this:
>
>
>        ' This is when we access the data provider in desktop and Web service mode
>        Sub New(ByVal toApplication As Framework.App)
>            oApp = toApplication
>        End Sub
>
>        ' This is when we access the data provider in a Web mode
>        Public Sub New(ByVal toProcess As Framework.LXProcess)
>            oProcess = toProcess
>        End Sub
>
>
>Then, one method of this class is like this:
>
>
>        ' Return the field size
>        ' expC1 Table
>        ' expC3 Connection string
>        Public Function GetSchema(ByVal tcTable As String, ByVal tcConnectionString As String) As Boolean
>            Dim loDataProvider As Framework.Data = New Framework.Data(oApp)
>            loDataProvider.nSQLMode = nSQLMode
>            If Not loDataProvider.GetSchemaTable(tcTable, tcConnectionString) Then
>                Return False
>            End If
>            oDataTable = loDataProvider.oDataTable
>            Return True
>        End Function
>
>
>However, in this method, when loDataProvider is created, the Framework.Data class also supports overloads. So, basically, if I instantiated this class by passing oApp, I need to have the declaration in this method to be:
>
>
>            Dim loDataProvider As Framework.Data = New Framework.Data(oApp)
>
>
>But, if I instantiated this class by passing oProcess, I need to have the declaration in this method to be:
>
>
>            Dim loDataProvider As Framework.Data = New Framework.Data(oProcess)
>
>
>Both lines would work and this is ok. However, in the GetSchema() method, how one would adjust the code to support that?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform