Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to overload property accessors
Message
From
05/03/2010 03:17:28
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
How to overload property accessors
Environment versions
Environment:
VB 9.0
Miscellaneous
Thread ID:
01452695
Message ID:
01452695
Views:
70
Hi,
Problem description. I want to OVERLOAD property in subclass

My BaseClass implement this property from Interface.
In Subclass I want to overwrite SET()
I put the MESSAGEBOX in the SET() but it does not fired. Only BaseClass Set() appears in Debugger.
The question is..
How can I overload property settor?


Here is an example.

Thanks
Denis
' INTERFACE
Public Interface IMyDriver
     Property DataSource() As String
 End Interface

' BASE CLASS
Public MustInherit Class MyBaseDriver
    Implements IMyDriver
     Private _pmks_datasource As String
      Public Overridable Property DataSource() As String Implements IMyDriver.DataSource
        Get
            Return (_pmks_datasource)
        End Get
        Set(ByVal value As String)
            _pmks_datasource = value
        End Set
    End Property
End Class

'SUBCLASS
Public Class MyTextDriver
    Inherits MyBaseDriver

    Private _pmks_datasource As String

    Public Overloads Property DataSource() As String
        Get
            Return (_pmks_datasource)
        End Get
        Set(ByVal value As String)
            MessageBox.Show(value)
            _pmks_datasource = value
            If File.Exists(value) Then
                If Path.GetFileName(value).IndexOf("-") >= 0 Then
                    Dim lcNewFilename As String = String.Format("{0}\{1}", Path.GetDirectoryName(value), Path.GetFileName(value).Replace("-", "_"))
            Try
                    Dim loFInfo As FileInfo = New FileInfo(value)
                    If File.Exists(lcNewFilename) Then
                        Kill(lcNewFilename)
                    End If
                    loFInfo.CopyTo(lcNewFilename)
                    _pmks_datasource = lcNewFilename
            Catch ex As Exception
                    _pmks_datasource = ""
            End Try

                End If
            End If
        End Set
    End Property

End Class
Next
Reply
Map
View

Click here to load this message in the networking platform