473,544 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HOWTO: Map interface declaration to a base class method? - TIA

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 (BaseRemoteData Object) 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
BaseRemoteDataO bject.DataRow through class Person.

In other words, I want BaseRemoteDataO bject.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.Dat aRow Implements
IPerson.DataRow
Get
return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

Am I making sense to anyone? TIA
'************** *************** *************** *************** *************** **
' Sample Code
'************** *************** *************** *************** *************** **
MY ABSTRACT CLASS
Public MustInherit Class BaseRemoteDataO bject
Inherits BaseRemoteObjec t
Protected mstrConnectStri ng As String
Protected mDataRow As System.Data.Dat aRow

Public Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property
Public Property ConnectString() As String
Get
Return mstrConnectStri ng
End Get
Set(ByVal Value As String)
mstrConnectStri ng = 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(ByVa l 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 BaseRemoteDataO bject
Implements IPerson
Public Event HasChanged(ByVa l DataHasChanged As Boolean)
Implements IPerson.HasChan ged

'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.mstrConn ectString = Value
End Set
End Property

<< Most Code Omitted>>

End Class
Nov 20 '05 #1
4 2838
Hi Ray,

Please modifiy the DataRow Property in the ABSTRACT CLASS and MY
IMPLEMENTATION as follows.

'MY ABSTRACT CLASS
Public Overridable Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

'MY IMPLEMENTATION
Public Overrides Property DataRow() As DataRow Implements
IPerson.DataRow
Get
DataRow = MyBase.DataRow
End Get
Set(ByVal Value As DataRow)
MyBase.DataRow = Value
End Set
End Property

The Overrides keyword will inherit the DataRow property from the
BaseRemoteDataO bject class and it will implements IPerson.DataRow .

Did I misunderstand your meaning?
If you have any further related question, please feel free to let me know.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: Ray Dukes <rd****@emfbroa dcasting.com>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Subject: HOWTO: Map interface declaration to a base class method? - TIA
Message-ID: <fm************ *************** *****@4ax.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 127
NNTP-Posting-Host: 64.57.103.130
X-Complaints-To: ab***@prodigy.n et
X-Trace: newssvr25.news. prodigy.com 1062538299 ST000 64.57.103.130 (Tue, 02 Sep 2003 17:31:39 EDT)NNTP-Posting-Date: Tue, 02 Sep 2003 17:31:39 EDT
Organization : SBC http://yahoo.sbc.com
X-UserInfo1: Q[R_PJONGBWYR_LXI RHFJFTBTR\B@GXL N@GZ_GYO^ZWZUYI CD^RAQBKZQTZTX\ _I[^G_KGFNON[Z
OE_AZNVO^\XGGNT CIRPIJH[@RQKBXLRZ@CD^HK ANYVW@RLGEZEJN@ \_WZJBNZYYKVIOR]T]MNMG_
Z[YVWSCH_Q[GPC_A@CARQVXDSD A^M]@DRVUM@RBMDate: Tue, 02 Sep 2003 21:31:39 GMT
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
e.de!npeer.de.k pn-eurorings.net!i n.100proofnews. com!in.100proof news.com!prod
igy.com!prodigy .com!newsmst01. news.prodigy.co m!prodigy.com!p ostmaster.news. p
rodigy.com!news svr25.news.prod igy.com.POSTED! fbab4d1e!not-for-mailXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:133630
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

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 (BaseRemoteData Object) 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
BaseRemoteData Object.DataRow through class Person.

In other words, I want BaseRemoteDataO bject.DataRow to fulfill the
IPerson.DataRo w 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.Dat aRow Implements
IPerson.DataRo w
Get
return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

Am I making sense to anyone? TIA
'************* *************** *************** *************** *************** * **' Sample Code
'************* *************** *************** *************** *************** * **

MY ABSTRACT CLASS
Public MustInherit Class BaseRemoteDataO bject
Inherits BaseRemoteObjec t
Protected mstrConnectStri ng As String
Protected mDataRow As System.Data.Dat aRow

Public Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property
Public Property ConnectString() As String
Get
Return mstrConnectStri ng
End Get
Set(ByVal Value As String)
mstrConnectStri ng = 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(ByVa l 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 BaseRemoteDataO bject
Implements IPerson
Public Event HasChanged(ByVa l DataHasChanged As Boolean)
Implements IPerson.HasChan ged

'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.mstrConn ectString = Value
End Set
End Property

<< Most Code Omitted>>

End Class


Nov 20 '05 #2
My question is this:
When implementing an interface in a derived class, is there a way to
map the interface method definition (Implements IPerson.DataRow )
directly to the INHERITED function call, without having to provide an
implementation in the derived class.

In other words, I want to map IPerson.DataRow to
BaseRemoteDataO bject.DataRow WITHOUT overriding with a new
implementation in the Person class. I want the interface to use the
inherited behavior, not redefine the behavior.

(I've seen nothing in the documentation that indicates that this is
possible.)

Thanks very much for responding.

Ray Dukes

On Wed, 03 Sep 2003 08:14:16 GMT, v-******@online.m icrosoft.com (Peter
Huang [MSFT]) wrote:
Hi Ray,

Please modifiy the DataRow Property in the ABSTRACT CLASS and MY
IMPLEMENTATI ON as follows.

'MY ABSTRACT CLASS
Public Overridable Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

'MY IMPLEMENTATION
Public Overrides Property DataRow() As DataRow Implements
IPerson.DataRo w
Get
DataRow = MyBase.DataRow
End Get
Set(ByVal Value As DataRow)
MyBase.DataRow = Value
End Set
End Property

The Overrides keyword will inherit the DataRow property from the
BaseRemoteData Object class and it will implements IPerson.DataRow .

Did I misunderstand your meaning?
If you have any further related question, please feel free to let me know.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: Ray Dukes <rd****@emfbroa dcasting.com>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Subject: HOWTO: Map interface declaration to a base class method? - TIA
Message-ID: <fm************ *************** *****@4ax.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 127
NNTP-Posting-Host: 64.57.103.130
X-Complaints-To: ab***@prodigy.n et
X-Trace: newssvr25.news. prodigy.com 1062538299 ST000 64.57.103.130 (Tue,

02 Sep 2003 17:31:39 EDT)
NNTP-Posting-Date: Tue, 02 Sep 2003 17:31:39 EDT
Organizatio n: SBC http://yahoo.sbc.com
X-UserInfo1:

Q[R_PJONGBWYR_LXI RHFJFTBTR\B@GXL N@GZ_GYO^ZWZUYI CD^RAQBKZQTZTX\ _I[^G_KGFNON[Z
OE_AZNVO^\XGGN TCIRPIJH[@RQKBXLRZ@CD^HK ANYVW@RLGEZEJN@ \_WZJBNZYYKVIOR]T]MNMG_
Z[YVWSCH_Q[GPC_A@CARQVXDSD A^M]@DRVUM@RBM
Date: Tue, 02 Sep 2003 21:31:39 GMT
Path:

cpmsftngxa06.p hx.gbl!TK2MSFTN GP08.phx.gbl!ne wsfeed00.sul.t-online.de!t-onlin
e.de!npeer.de. kpn-eurorings.net!i n.100proofnews. com!in.100proof news.com!prod
igy.com!prodig y.com!newsmst01 .news.prodigy.c om!prodigy.com! postmaster.news .p
rodigy.com!new ssvr25.news.pro digy.com.POSTED !fbab4d1e!not-for-mail
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:133630
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

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 (BaseRemoteData Object) wants the derived
classes to use it's ConnectString and DataRow properties'
implementatio n, 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
BaseRemoteDat aObject.DataRow through class Person.

In other words, I want BaseRemoteDataO bject.DataRow to fulfill the
IPerson.DataR ow 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.Dat aRow Implements
IPerson.DataR ow
Get
return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

Am I making sense to anyone? TIA
'************ *************** *************** *************** *************** **

**
' Sample Code
'************ *************** *************** *************** *************** **

**


MY ABSTRACT CLASS
Public MustInherit Class BaseRemoteDataO bject
Inherits BaseRemoteObjec t
Protected mstrConnectStri ng As String
Protected mDataRow As System.Data.Dat aRow

Public Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property
Public Property ConnectString() As String
Get
Return mstrConnectStri ng
End Get
Set(ByVal Value As String)
mstrConnectStri ng = 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(ByVa l 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 BaseRemoteDataO bject
Implements IPerson
Public Event HasChanged(ByVa l DataHasChanged As Boolean)
Implements IPerson.HasChan ged

'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.mstrConn ectString = Value
End Set
End Property

<< Most Code Omitted>>

End Class


Nov 20 '05 #3
Hi Ray,

I will do some research and update you with new information ASAP.

Have a nice day.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: Ray Dukes <rd****@emfbroa dcasting.com>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Subject: Re: HOWTO: Map interface declaration to a base class method? - TIA
Message-ID: <gh************ *************** *****@4ax.com>
References: <fm************ *************** *****@4ax.com> <i#************ **@cpmsftngxa06 .phx.gbl>X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 221
NNTP-Posting-Host: 64.57.103.130
X-Complaints-To: ab***@prodigy.n et
X-Trace: newssvr25.news. prodigy.com 1062601764 ST000 64.57.103.130 (Wed, 03 Sep 2003 11:09:24 EDT)NNTP-Posting-Date: Wed, 03 Sep 2003 11:09:24 EDT
Organization : SBC http://yahoo.sbc.com
X-UserInfo1: OX][R\KG\ZWOR^I]^JKBOW@@YJ_ZTB\ MV@BZMVMHQAVTUZ]CLNTCPFK[WDXDHV[K^FCGJCJLPF_D
_NCC@FUG^Q\DINV AXSLIFXYJSSCCAL P@PB@\OS@BITWAH \CQZKJMMD^SJA^N XA\GVLSRBD^M_NW _
F[YLVTWIGAXAQBOAT KBBQRXECDFDMQ\D ZFUE@\JMDate: Wed, 03 Sep 2003 15:09:24 GMT
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
e.de!skynet.be! skynet.be!newsg ate.cistron.nl! amsnews01.chell o.com!in.100pro o
fnews.com!in.10 0proofnews.com! prodigy.com!new smst01.news.pro digy.com!prodig y
..com!postmaste r.news.prodigy. com!newssvr25.n ews.prodigy.com .POSTED!fbab4d1 e!
not-for-mailXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:133817
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

My question is this:
When implementing an interface in a derived class, is there a way to
map the interface method definition (Implements IPerson.DataRow )
directly to the INHERITED function call, without having to provide an
implementati on in the derived class.

In other words, I want to map IPerson.DataRow to
BaseRemoteData Object.DataRow WITHOUT overriding with a new
implementati on in the Person class. I want the interface to use the
inherited behavior, not redefine the behavior.

(I've seen nothing in the documentation that indicates that this is
possible.)

Thanks very much for responding.

Ray Dukes

On Wed, 03 Sep 2003 08:14:16 GMT, v-******@online.m icrosoft.com (Peter
Huang [MSFT]) wrote:
Hi Ray,

Please modifiy the DataRow Property in the ABSTRACT CLASS and MY
IMPLEMENTATIO N as follows.

'MY ABSTRACT CLASS
Public Overridable Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

'MY IMPLEMENTATION
Public Overrides Property DataRow() As DataRow Implements
IPerson.DataR ow
Get
DataRow = MyBase.DataRow
End Get
Set(ByVal Value As DataRow)
MyBase.DataRow = Value
End Set
End Property

The Overrides keyword will inherit the DataRow property from the
BaseRemoteDat aObject class and it will implements IPerson.DataRow .

Did I misunderstand your meaning?
If you have any further related question, please feel free to let me know.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.--------------------
From: Ray Dukes <rd****@emfbroa dcasting.com>
Newsgroups : microsoft.publi c.dotnet.langua ges.vb
Subject: HOWTO: Map interface declaration to a base class method? - TIA
Message-ID: <fm************ *************** *****@4ax.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 127
NNTP-Posting-Host: 64.57.103.130
X-Complaints-To: ab***@prodigy.n et
X-Trace: newssvr25.news. prodigy.com 1062538299 ST000 64.57.103.130 (Tue,

02 Sep 2003 17:31:39 EDT)
NNTP-Posting-Date: Tue, 02 Sep 2003 17:31:39 EDT
Organization : SBC http://yahoo.sbc.com
X-UserInfo1:

Q[R_PJONGBWYR_LXI RHFJFTBTR\B@GXL N@GZ_GYO^ZWZUYI CD^RAQBKZQTZTX\ _I[^G_KGFNON [ZOE_AZNVO^\XGG NTCIRPIJH[@RQKBXLRZ@CD^HK ANYVW@RLGEZEJN@ \_WZJBNZYYKVIOR]T]MNM G_Z[YVWSCH_Q[GPC_A@CARQVXDSD A^M]@DRVUM@RBM
Date: Tue, 02 Sep 2003 21:31:39 GMT
Path:

cpmsftngxa06. phx.gbl!TK2MSFT NGP08.phx.gbl!n ewsfeed00.sul.t-online.de!t-onl ine.de!npeer.de .kpn-eurorings.net!i n.100proofnews. com!in.100proof news.com!pr odigy.com!prodi gy.com!newsmst0 1.news.prodigy. com!prodigy.com !postmaster.new s ..prodigy.com!ne wssvr25.news.pr odigy.com.POSTE D!fbab4d1e!not-for-mail
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:133630
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

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 (BaseRemoteData Object) wants the derived
classes to use it's ConnectString and DataRow properties'
implementati on, 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
BaseRemoteDa taObject.DataRo w through class Person.

In other words, I want BaseRemoteDataO bject.DataRow to fulfill the
IPerson.Data Row 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.Dat aRow Implements
IPerson.Data Row
Get
return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

Am I making sense to anyone? TIA
'*********** *************** *************** *************** *************** *
****
' Sample Code
'*********** *************** *************** *************** *************** *
****


MY ABSTRACT CLASS
Public MustInherit Class BaseRemoteDataO bject
Inherits BaseRemoteObjec t
Protected mstrConnectStri ng As String
Protected mDataRow As System.Data.Dat aRow

Public Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property
Public Property ConnectString() As String
Get
Return mstrConnectStri ng
End Get
Set(ByVal Value As String)
mstrConnectStri ng = 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(ByVa l 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 BaseRemoteDataO bject
Implements IPerson
Public Event HasChanged(ByVa l DataHasChanged As Boolean)
Implements IPerson.HasChan ged

'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.mstrConn ectString = Value
End Set
End Property

<< Most Code Omitted>>

End Class



Nov 20 '05 #4
Hi Ray,

Based on my experience, you can not I want to implement IPerson.DataRow by
mappting to the Base class without overriding with a new implementation in
the Person class.

You may do it as what I post in the last post.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
X-Tomcat-ID: 236409730
References: <fm************ *************** *****@4ax.com> <i#************ **@cpmsftngxa06 .phx.gbl>
<gh************ *************** *****@4ax.com>MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: v-******@online.m icrosoft.com (Peter Huang [MSFT])
Organization : Microsoft
Date: Thu, 04 Sep 2003 09:15:29 GMT
Subject: Re: HOWTO: Map interface declaration to a base class method? - TIA
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
Message-ID: <p3************ **@cpmsftngxa06 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Lines: 240
Path: cpmsftngxa06.ph x.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:134106
NNTP-Posting-Host: TOMCATIMPORT2 10.201.218.182

Hi Ray,

I will do some research and update you with new information ASAP.

Have a nice day.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
From: Ray Dukes <rd****@emfbroa dcasting.com>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Subject: Re: HOWTO: Map interface declaration to a base class method? - TIA
Message-ID: <gh************ *************** *****@4ax.com>
References: <fm************ *************** *****@4ax.com><i#*********** ***@cpmsftngxa0 6.phx.gbl>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 221
NNTP-Posting-Host: 64.57.103.130
X-Complaints-To: ab***@prodigy.n et
X-Trace: newssvr25.news. prodigy.com 1062601764 ST000 64.57.103.130 (Wed,

03 Sep 2003 11:09:24 EDT)
NNTP-Posting-Date: Wed, 03 Sep 2003 11:09:24 EDT
Organizatio n: SBC http://yahoo.sbc.com
X-UserInfo1:

OX][R\KG\ZWOR^I]^JKBOW@@YJ_ZTB\ MV@BZMVMHQAVTUZ]CLNTCPFK[WDXDHV[K^FCGJCJLPF_

D_NCC@FUG^Q\DIN VAXSLIFXYJSSCCA LP@PB@\OS@BITWA H\CQZKJMMD^SJA^ NXA\GVLSRBD^M_N W _F[YLVTWIGAXAQBOAT KBBQRXECDFDMQ\D ZFUE@\JM
Date: Wed, 03 Sep 2003 15:09:24 GMT
Path:cpmsftngxa06.p hx.gbl!TK2MSFTN GP08.phx.gbl!ne wsfeed00.sul.t-online.de!t-onli

ne.de!skynet.be !skynet.be!news gate.cistron.nl !amsnews01.chel lo.com!in.100pr o ofnews.com!in.1 00proofnews.com !prodigy.com!ne wsmst01.news.pr odigy.com!prodi g y.com!postmaste r.news.prodigy. com!newssvr25.n ews.prodigy.com .POSTED!fbab4d1 e !not-for-mail
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:133817
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

My question is this:
When implementing an interface in a derived class, is there a way to
map the interface method definition (Implements IPerson.DataRow )
directly to the INHERITED function call, without having to provide an
implementatio n in the derived class.

In other words, I want to map IPerson.DataRow to
BaseRemoteDat aObject.DataRow WITHOUT overriding with a new
implementatio n in the Person class. I want the interface to use the
inherited behavior, not redefine the behavior.

(I've seen nothing in the documentation that indicates that this is
possible.)

Thanks very much for responding.

Ray Dukes

On Wed, 03 Sep 2003 08:14:16 GMT, v-******@online.m icrosoft.com (Peter
Huang [MSFT]) wrote:
Hi Ray,

Please modifiy the DataRow Property in the ABSTRACT CLASS and MY
IMPLEMENTATI ON as follows.

'MY ABSTRACT CLASS
Public Overridable Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

'MY IMPLEMENTATION
Public Overrides Property DataRow() As DataRow Implements
IPerson.Data Row
Get
DataRow = MyBase.DataRow
End Get
Set(ByVal Value As DataRow)
MyBase.DataRow = Value
End Set
End Property

The Overrides keyword will inherit the DataRow property from the
BaseRemoteDa taObject class and it will implements IPerson.DataRow .

Did I misunderstand your meaning?
If you have any further related question, please feel free to let me know.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.--------------------
From: Ray Dukes <rd****@emfbroa dcasting.com>
Newsgroup s: microsoft.publi c.dotnet.langua ges.vb
Subject: HOWTO: Map interface declaration to a base class method? - TIA
Message-ID: <fm************ *************** *****@4ax.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 127
NNTP-Posting-Host: 64.57.103.130
X-Complaints-To: ab***@prodigy.n et
X-Trace: newssvr25.news. prodigy.com 1062538299 ST000 64.57.103.130 (Tue,02 Sep 2003 17:31:39 EDT)
NNTP-Posting-Date: Tue, 02 Sep 2003 17:31:39 EDT
Organizatio n: SBC http://yahoo.sbc.com
X-UserInfo1:
Q[R_PJONGBWYR_LXI RHFJFTBTR\B@GXL N@GZ_GYO^ZWZUYI CD^RAQBKZQTZTX\ _I[^G_KGFNO
N[ZOE_AZNVO^\XG GNTCIRPIJH[@RQKBXLRZ@CD^HK ANYVW@RLGEZEJN@ \_WZJBNZYYKVIOR]T]MN
M
G_Z[YVWSCH_Q[GPC_A@CARQVXDSD A^M]@DRVUM@RBM
Date: Tue, 02 Sep 2003 21:31:39 GMT
Path:
cpmsftngxa06 .phx.gbl!TK2MSF TNGP08.phx.gbl! newsfeed00.sul. t-online.de!t-on
l
ine.de!npeer.d e.kpn-eurorings.net!i n.100proofnews. com!in.100proof news.com!p
r
odigy.com!prod igy.com!newsmst 01.news.prodigy .com!prodigy.co m!postmaster.ne w
s
.prodigy.com!n ewssvr25.news.p rodigy.com.POST ED!fbab4d1e!not-for-mail
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:133630
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

What I am looking to do is map the implementation of interface
propertie s and functions to an inherited method of the base class.

Please see below.

'********** *************** *************** *************** *************** *
*
****
' Issues
'********** *************** *************** *************** *************** *
*
****
Note:
1. The abstract class (BaseRemoteData Object) wants the derived
classes to use it's ConnectString and DataRow properties'
implementat ion, but requires the data manipulation methods to be
overridde n.

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
BaseRemoteD ataObject.DataR ow through class Person.

In other words, I want BaseRemoteDataO bject.DataRow to fulfill the
IPerson.Dat aRow 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.Dat aRow Implements
IPerson.Dat aRow
Get
return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property

Am I making sense to anyone? TIA
'********** *************** *************** *************** *************** *
*
****
' Sample Code
'********** *************** *************** *************** *************** *
*
****
MY ABSTRACT CLASS
Public MustInherit Class BaseRemoteDataO bject
Inherits BaseRemoteObjec t
Protected mstrConnectStri ng As String
Protected mDataRow As System.Data.Dat aRow

Public Property DataRow() As System.Data.Dat aRow
Get
Return mDataRow
End Get
Set(ByVal Value As System.Data.Dat aRow)
mDataRow = Value
End Set
End Property
Public Property ConnectString() As String
Get
Return mstrConnectStri ng
End Get
Set(ByVal Value As String)
mstrConnectStri ng = 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(ByVa l 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 BaseRemoteDataO bject
Implements IPerson
Public Event HasChanged(ByVa l DataHasChanged As Boolean)
Implement s IPerson.HasChan ged

'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.mstrConn ectString = Value
End Set
End Property

<< Most Code Omitted>>

End Class




Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
277
by: Kannan | last post by:
hi My question might be a simple questions. I am doing C# maintanance project I have seen so many places Interface is used in my main class. But I could't not understan what is the use of Interface. Because Interface having only the Property and method declaration only. Why we have to use that instead of writing directly in the main class? ...
6
3005
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
20
4224
by: Ole Hanson | last post by:
I am accessing my database through an interface, to allow future substitution of the physical datastore - hence I would like to declare in my Interface that my DAL-objects implementing the interface and accessing the datastore MUST pass in a UserToken in the constructor of the object. Is this not possible? Am I forced to add the UserToken...
9
7542
by: phl | last post by:
hi, I am kind of confused aobut interfaces and abstract classes. In short as I understand it, an interface is like a contract between the class and the interface, so that certain funtions must be implemented. So if you have a class which inherits base class that inherts an interface, then your classes will have a standard. I suppose you...
15
12767
by: jon | last post by:
How can I call a base interface method? class ThirdPartyClass :IDisposable { //I can not modify this class void IDisposable.Dispose() { Console.WriteLine( "ThirdPartyClass Dispose" ); } } class MyClass :ThirdPartyClass, IDisposable { void IDisposable.Dispose() {
7
15645
by: moondaddy | last post by:
If I'm in a class that inherits an interface, is there a shortcut key that will write the implementation of the interface into the class? I remember seeing something like this in vb.net. Thanks. -- moondaddy@nospam.nospam
2
1754
by: fred | last post by:
Hi, Why should I do a cast (IOfferSetter) in the constructor of the Test class? Thanks. Fred public interface IOfferSetter { object Offer { set;} } public class OfferCtx {
5
1587
by: The Cool Giraffe | last post by:
I'm designing an ABC and in connection to that i have run into some "huh!" and "oh...". Let me put it as a list. 1. Since the class will only contain bodies of the methods, only the header file is needed. There will be no definitions provided until i derive the ABC. True or false? 2. Since i'll have two different classes (both derived...
13
1532
by: Ben Voigt [C++ MVP] | last post by:
This is more of a C# question than a C++ question, but my best chance of explaining it is via comparison to C++. Ok: In C++ you can forward declare a type. Then references to that type can be passed around in a typesafe way without introducing a dependency on the type. Only users needing to access the members need the type definition. ...
0
7359
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7598
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7360
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7699
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3400
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3398
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1833
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
651
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.