I'm hoping that someone out there can give me some guidance here, and I hope that I am explaining this properly.
Here is my scenerio:
I have a BaseData object that serves as an abstract object for all my business objects. Notice there is an overridable method on the object.
Here is the base Collection that servers as the abstract collection for all my business object collections:
Here is an example of a derived object that inherits BaseData:
Here is an example of a derived collection:
When I try to databind the result from MyUser.GetAllOb jects to my gridView I am only seeing the BASEDATA object properties of DataID and Description. What am I doing wrong? I thought that the rules of polymorphism would strongly type the BindingList (of BaseData) in to BindingList (of MyUser) but that does not appear to be the case.
Any help would be greatly appreciated.
Here is my scenerio:
I have a BaseData object that serves as an abstract object for all my business objects. Notice there is an overridable method on the object.
Code:
Public Class BaseData
Dim msDataID As String
Dim msDescription As String
<DataMember()>
Property DataID() As String
Get
DataID = msDataID
End Get
Set(ByVal value As String)
msDataID = value
End Set
End Property
Property Description() As String
Get
Description = msDescription
End Get
Set(ByVal value As String)
msDescription = value
End Set
End Property
Public Overridable Function GetAllObjects() As BaseDataCollection
Dim colObjects As BaseDataCollection = Nothing
colObjects = (get data from data source)
Return colObjects
End Function
End Class
Here is the base Collection that servers as the abstract collection for all my business object collections:
Code:
Public Class BaseDataCollection
Inherits BindingList(Of BaseData)
Implements IComponent
#Region "IComponent Implementation"
Private m_Site As ISite = Nothing
Public Event Disposed(ByVal sender As Object, ByVal e As System.EventArgs) _
Implements System.ComponentModel.IComponent.Disposed
Protected Property Site() As System.ComponentModel.ISite Implements _
System.ComponentModel.IComponent.Site
Get
Return m_Site
End Get
Set(ByVal Value As System.ComponentModel.ISite)
m_Site = Value
End Set
End Property
Public Sub Dispose() Implements System.IDisposable.Dispose
Me.Items.Clear()
RaiseEvent Disposed(Me, System.EventArgs.Empty)
End Sub
#End Region
#Region "IBindingList Sorting Features"
Private m_SupportsSorting As Boolean = True
Private m_SortProperty As PropertyDescriptor
Private m_SortDirection As ListSortDirection
Private m_OriginalList As ArrayList
Protected Overrides ReadOnly Property SupportsSortingCore() As Boolean
Get
Return m_SupportsSorting
End Get
End Property
Protected Overrides ReadOnly Property SortDirectionCore() As System.ComponentModel.ListSortDirection
Get
Return m_SortDirection
End Get
End Property
Protected Overrides ReadOnly Property SortPropertyCore() As System.ComponentModel.PropertyDescriptor
Get
Return m_SortProperty
End Get
End Property
Protected Overrides ReadOnly Property IsSortedCore() As Boolean
Get
Return m_SortProperty Is Nothing
End Get
End Property
Private Sub SaveList()
m_OriginalList = New ArrayList(Me.Items)
End Sub
Private Sub ResetList(ByVal NewList As ArrayList)
Me.ClearItems()
For Each m_Student As BaseData In NewList
Me.Add(m_Student)
Next
End Sub
Private Sub DoSort()
Dim m_Comparer As New BaseDataComparer(m_SortProperty, m_SortDirection)
Dim m_SortList As New ArrayList(Me.Items)
m_SortList.Sort(m_Comparer)
ResetList(m_SortList)
End Sub
Protected Overrides Sub ApplySortCore(ByVal prop As System.ComponentModel.PropertyDescriptor, ByVal direction As System.ComponentModel.ListSortDirection)
m_SortProperty = prop
m_SortDirection = direction
If (m_OriginalList Is Nothing) Then
SaveList()
End If
DoSort()
End Sub
Protected Overrides Sub RemoveSortCore()
ResetList(m_OriginalList)
m_SortDirection = Nothing
m_SortProperty = Nothing
End Sub
#End Region
End Class
Code:
Public Class MyUser
Inherits BaseData
Dim msUserName As String
Dim msPassword As String
Public Property UserName As String
Get
Return msUserName
End Get
Set(ByVal value As String)
msUserName = value
End Set
End Property
Public Property Password As String
Get
Return msPassword
End Get
Set(ByVal value As String)
msPassword = value
End Set
End Property
Public Overrides Function GetAllObjects() As Collections.BaseDataCollection
Dim GetParams As New stcReadFileParams
Dim myProcessor As New MasterProcessor
Dim sObjectRec As String = ""
Dim colObject As Collections.MyUserCollection = Nothing
GetParams.FileName = FileName
GetParams.KeyWord = RN_USERS
GetParams.Mode = MODE_INQUIRY
If Not UVSession Is Nothing Then myProcessor.UVSession = UVSession
sObjectRec = myProcessor.GetMaster(GetParams)
If sObjectRec <> "" Then
colObject = ParseRecordIntoObjects(sObjectRec)
End If
Return colObject
End Function
End Class
Here is an example of a derived collection:
Code:
Public Class MyUserCollection
Inherits BaseDataCollection
End Class
Any help would be greatly appreciated.