R
Ray Dukes
What I am looking to do is map the implementation of interface
properties and functions to an inherited method of the base class.
Please see below.
'****************************************************************************
' Issues
'****************************************************************************
Note:
1. The abstract class (BaseRemoteDataObject) wants the derived
classes to use it's ConnectString and DataRow properties'
implementation, but requires the data manipulation methods to be
overridden.
2. The interface that the clients will use (IPerson) allows
access to the DataRow, but not the ConnectString. It also edxposes
the data manipulation methods.
3. The public interface for the implementation class (Person)
only allows Write access to the ConnectString (which IPerson doesn't
recognize)
QUESTION: How do I map IPerson.DataRow() to
BaseRemoteDataObject.DataRow through class Person.
In other words, I want BaseRemoteDataObject.DataRow to fulfill the
IPerson.DataRow requirement in Person.DataRow.
Do I have to provide a pass through implementation for each
method/property to mybase.property?
Public Property DataRow() As System.Data.DataRow Implements
IPerson.DataRow
Get
return mDataRow
End Get
Set(ByVal Value As System.Data.DataRow)
mDataRow = Value
End Set
End Property
Am I making sense to anyone? TIA
'****************************************************************************
' Sample Code
'****************************************************************************
MY ABSTRACT CLASS
Public MustInherit Class BaseRemoteDataObject
Inherits BaseRemoteObject
Protected mstrConnectString As String
Protected mDataRow As System.Data.DataRow
Public Property DataRow() As System.Data.DataRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.DataRow)
mDataRow = Value
End Set
End Property
Public Property ConnectString() As String
Get
Return mstrConnectString
End Get
Set(ByVal Value As String)
mstrConnectString = Value
End Set
End Property
Public MustOverride Function CancelChanges() As Boolean
Public MustOverride Function Clear() As Boolean
Public MustOverride Function Retrieve(ByVal ID As Integer) As
Integer
Public MustOverride Function Save() As Integer
End Class
MY INTERFACE
Public Interface IPerson
Event HasChanged(ByVal DataHasChanged As Boolean)
ReadOnly Property ID() As Int32
Property FirstName() As String
Property LastName() As String
ReadOnly Property IsChanged() As Boolean
Property DataRow() As DataRow
Function Retrieve(ByVal ID As Int32) As Int32
Function Save() As Int32
Function Clear() As Boolean
Function CancelChanges() As Boolean
End Interface
MY IMPLEMENTATION
Public Class Person
Inherits BaseRemoteDataObject
Implements IPerson
Public Event HasChanged(ByVal DataHasChanged As Boolean)
Implements IPerson.HasChanged
'Original Property Values
Protected p_strFirstname As String
Protected p_strLastname As String
Protected p_intID As Int32
'Current Property Values
Protected strFirstname As String
Protected strLastname As String
Protected intID As Int32
Protected blnChanged As Boolean
Public Shadows WriteOnly Property ConnectString() As String
Set(ByVal Value As String)
MyBase.mstrConnectString = Value
End Set
End Property
<< Most Code Omitted>>
End Class
properties and functions to an inherited method of the base class.
Please see below.
'****************************************************************************
' Issues
'****************************************************************************
Note:
1. The abstract class (BaseRemoteDataObject) wants the derived
classes to use it's ConnectString and DataRow properties'
implementation, but requires the data manipulation methods to be
overridden.
2. The interface that the clients will use (IPerson) allows
access to the DataRow, but not the ConnectString. It also edxposes
the data manipulation methods.
3. The public interface for the implementation class (Person)
only allows Write access to the ConnectString (which IPerson doesn't
recognize)
QUESTION: How do I map IPerson.DataRow() to
BaseRemoteDataObject.DataRow through class Person.
In other words, I want BaseRemoteDataObject.DataRow to fulfill the
IPerson.DataRow requirement in Person.DataRow.
Do I have to provide a pass through implementation for each
method/property to mybase.property?
Public Property DataRow() As System.Data.DataRow Implements
IPerson.DataRow
Get
return mDataRow
End Get
Set(ByVal Value As System.Data.DataRow)
mDataRow = Value
End Set
End Property
Am I making sense to anyone? TIA
'****************************************************************************
' Sample Code
'****************************************************************************
MY ABSTRACT CLASS
Public MustInherit Class BaseRemoteDataObject
Inherits BaseRemoteObject
Protected mstrConnectString As String
Protected mDataRow As System.Data.DataRow
Public Property DataRow() As System.Data.DataRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.DataRow)
mDataRow = Value
End Set
End Property
Public Property ConnectString() As String
Get
Return mstrConnectString
End Get
Set(ByVal Value As String)
mstrConnectString = Value
End Set
End Property
Public MustOverride Function CancelChanges() As Boolean
Public MustOverride Function Clear() As Boolean
Public MustOverride Function Retrieve(ByVal ID As Integer) As
Integer
Public MustOverride Function Save() As Integer
End Class
MY INTERFACE
Public Interface IPerson
Event HasChanged(ByVal DataHasChanged As Boolean)
ReadOnly Property ID() As Int32
Property FirstName() As String
Property LastName() As String
ReadOnly Property IsChanged() As Boolean
Property DataRow() As DataRow
Function Retrieve(ByVal ID As Int32) As Int32
Function Save() As Int32
Function Clear() As Boolean
Function CancelChanges() As Boolean
End Interface
MY IMPLEMENTATION
Public Class Person
Inherits BaseRemoteDataObject
Implements IPerson
Public Event HasChanged(ByVal DataHasChanged As Boolean)
Implements IPerson.HasChanged
'Original Property Values
Protected p_strFirstname As String
Protected p_strLastname As String
Protected p_intID As Int32
'Current Property Values
Protected strFirstname As String
Protected strLastname As String
Protected intID As Int32
Protected blnChanged As Boolean
Public Shadows WriteOnly Property ConnectString() As String
Set(ByVal Value As String)
MyBase.mstrConnectString = Value
End Set
End Property
<< Most Code Omitted>>
End Class