VB.NET, templates, reflection, inheritance, feeling adrift
Posted
by brovar
on Stack Overflow
See other posts from Stack Overflow
or by brovar
Published on 2010-05-11T12:38:43Z
Indexed on
2010/05/12
21:54 UTC
Read the original article
Hit count: 392
I've just made myself up a problem and am now wondering how to solve it.
To begin with, I'm using some third-party components, including some calendar controls like schedule and timeline. They're used in the project classes more or less like that:
Friend Class TimeBasedDataView
'some members
End Class
Friend Class ScheduleDataView
Inherits TimeBasedDataView
Public Schedule As Controls.Schedule.Schedule
'and others
End Class
Friend Class TimeLineDataView
Inherits TimeBasedDataView
Public TimeLine As Controls.TimeLine.TimeLine
'and others
End Class
(Hmm, code coloring fail, never mind...) Now, to allow managing the look of data being presented there are some mechanisms including so called Style Managers. A lot of code in them repeats, varying almost only with the control it maintains:
Friend Class TimeLineStyleManager
Private m_TimeLine As TimeLineDataView
Private Sub Whatever()
m_TimeLine.TimeLine.SomeProperty = SomeValue
End Sub
End Class
Friend Class ScheduleStyleManager
Private m_Schedule As ScheduleDataView
Private Sub Whatever()
m_Schedule.Schedule.SomeProperty = SomeValue
End Sub
End Class
I was wondering if I could create some base class for those managers, like
Friend Class TimeBasedCtrlStyleManagerBase(Of T As TimeBasedDataView)
Private m_Control As T
'and others
End Class
which would unify these two, but I've got lost when it came to maintaining two components that have nothing in common (except their properties' names, etc.). Type reflection maybe? I'll be grateful for any advice ;)
© Stack Overflow or respective owner