Reputation: 5149
I have 2 interfaces, IAccount and IEmailAccount. IEmailAccount contains all of the same properties and methods as IAccount, plus a few extensions related to email. Is there a way to do something similar to class inheritance with Interfaces? I tried removing all of the common properties/methods shared between the 2 from IEmailAccount, but if I have a List of IAccounts, I want to be able to include IEmailAccounts in that list...
Public Interface IAccount
Property Username As String
Property Password As String
Property LoginCookie As Net.CookieContainer
Property CreationDate As Date
Property LastLoginDate As Date
Property EmailAccount As IEmailAccount
Property Proxy As HelperLib.Proxy
Sub Login()
Sub Create()
End Interface
Public Interface IEmailAccount
Property Username As String
Property Password As String
Property LoginCookie As Net.CookieContainer
Property CreationDate As Date
Property LastLoginDate As Date
Property EmailAccount As IEmailAccount
Property Proxy As HelperLib.Proxy
Property Emails As List(Of Email)
Sub Login()
Sub Create()
Sub SendMail(recipient As String, title As String, body As String)
Function GetEmails() As List(Of Email)
End Interface
Public MustInherit Class EmailAccountBase
Implements IEmailAccount
Implements IAccount
Public Property Emails As List(Of Email) Implements IEmailAccount.Emails
Public Property Username As String Implements IEmailAccount.Username, IAccount.Username
Public Property Password As String Implements IEmailAccount.Password, IAccount.Password
Public Property LoginCookie As CookieContainer Implements IEmailAccount.LoginCookie, IAccount.LoginCookie
Public Property CreationDate As Date Implements IEmailAccount.CreationDate, IAccount.CreationDate
Public Property LastLoginDate As Date Implements IEmailAccount.LastLoginDate, IAccount.LastLoginDate
Public Property EmailAccount As IEmailAccount Implements IEmailAccount.EmailAccount, IAccount.EmailAccount
Public Property Proxy As Proxy Implements IEmailAccount.Proxy, IAccount.Proxy
Public MustOverride Sub Login() Implements IEmailAccount.Login, IAccount.Login
Public MustOverride Sub Create() Implements IEmailAccount.Create, IAccount.Create
Public MustOverride Sub SendMail(recipient As String, title As String, body As String) Implements IEmailAccount.SendMail
Public MustOverride Function GetEmails() As List(Of Email) Implements IEmailAccount.GetEmails
Public Sub New(username As String, password As String)
Me.Username = username
Me.Password = password
End Sub
End Class
Upvotes: 0
Views: 41
Reputation: 117064
Yes, it's simple:
Public Interface IAccount
Property Username As String
Property Password As String
Property LoginCookie As Net.CookieContainer
Property CreationDate As Date
Property LastLoginDate As Date
Property EmailAccount As IEmailAccount
Property Proxy As HelperLib.Proxy
Sub Login()
Sub Create()
End Interface
Public Interface IEmailAccount
Inherits IAccount
Property Emails As List(Of Email)
Sub SendMail(recipient As String, title As String, body As String)
Function GetEmails() As List(Of Email)
End Interface
Upvotes: 1