Am I just going mad again ???
I have a must inherit base class (Service) and two implementations (Imp1, Imp2). Everything is shared.
I had rather hoped that inheriting said base class would cause Imp1 and Imp2 to extend it independantly. They don't.
Why. I mean if it were instances it wouldn't be true. Seems a bit weird (probably serves me right for using VB.... )
Example:-
Public MustInherit Class Service
Private Shared s_objLogger As aaLogger
Private Shared s_blnSimulated As Boolean
Friend Shared Sub Init(ByVal tag As String)
Dim strTagLog As String = "aaa." & tag
'Create the logger
s_objLogger = new aaLogger(strTagLog)
'Extract whether we are real or simulated.
s_blnSimulated = GetSetting.Simulated(tag)
End Sub
Shared ReadOnly Property Simulated() As Boolean
Get
Simulated = s_blnSimulated
End Get
End Property
Shared ReadOnly Property Logger() As aaLogger
Get
Logger = s_objLogger
End Get
End Property
End Class
And a concrete class....
Public Class Imp1
Inherits Service
Const S_TAG As String = "aa"
Shared Sub New()
Service.Init(S_TAG)
End Sub
Shared Function SomeFunc() As Integer
End Function
end class
And another
Public Class Imp2
Inherits Service
Const S_TAG As String = "bb"
Shared Sub New()
Service.Init(S_TAG)
End Sub
Shared Function SomeFunc() As Integer
End Function
end class
......
imp1.somemethod
imp2.somemethod
if imp1.logger = imp2.logger print "bugger"
I have a must inherit base class (Service) and two implementations (Imp1, Imp2). Everything is shared.
I had rather hoped that inheriting said base class would cause Imp1 and Imp2 to extend it independantly. They don't.
Why. I mean if it were instances it wouldn't be true. Seems a bit weird (probably serves me right for using VB.... )
Example:-
Public MustInherit Class Service
Private Shared s_objLogger As aaLogger
Private Shared s_blnSimulated As Boolean
Friend Shared Sub Init(ByVal tag As String)
Dim strTagLog As String = "aaa." & tag
'Create the logger
s_objLogger = new aaLogger(strTagLog)
'Extract whether we are real or simulated.
s_blnSimulated = GetSetting.Simulated(tag)
End Sub
Shared ReadOnly Property Simulated() As Boolean
Get
Simulated = s_blnSimulated
End Get
End Property
Shared ReadOnly Property Logger() As aaLogger
Get
Logger = s_objLogger
End Get
End Property
End Class
And a concrete class....
Public Class Imp1
Inherits Service
Const S_TAG As String = "aa"
Shared Sub New()
Service.Init(S_TAG)
End Sub
Shared Function SomeFunc() As Integer
End Function
end class
And another
Public Class Imp2
Inherits Service
Const S_TAG As String = "bb"
Shared Sub New()
Service.Init(S_TAG)
End Sub
Shared Function SomeFunc() As Integer
End Function
end class
......
imp1.somemethod
imp2.somemethod
if imp1.logger = imp2.logger print "bugger"
Comment