I am writing an application that uses a custom class which inherits
DictionaryBase so that I can add items with an associated key. When I try to
serialize the object though, I get the following error: The type
BuildingsCollec tion is not supported because it implements IDictionary. Here
is my class:
Namespace BusinessLogicLa yer
<Serializable() > _
Public Class BuildingsCollec tion
Inherits DictionaryBase
Default Property Item(ByVal key As String) As Building
Get
Return Me.Dictionary.I tem(key)
End Get
Set(ByVal Value As Building)
Me.Dictionary.I tem(key) = Value
End Set
End Property
Public Sub Add(ByVal item As Building, ByVal key As String)
Dictionary.Add( key, item)
End Sub
Public Function Contains(ByVal key As String) As Boolean
Return Dictionary.Cont ains(key)
End Function
Public ReadOnly Property Keys() As ICollection
Get
Return Dictionary.Keys
End Get
End Property
Public ReadOnly Property Values() As ICollection
Get
Return Dictionary.Valu es
End Get
End Property
Public Sub Remove(ByVal key As String)
Me.Dictionary.R emove(key)
End Sub
End Class
End Namespace
Do I have to do anything special to it to allow me to serialize to XML? The
Building object seen in the class is just what I want my collection to be of
so other objects will not work. The building class will work with
serialization. In my main app I have a "Person" class defined with the
following: Private pBuildings as BuildingsCollec tion, since one person could
have more than one building.
Thanks in advance...
- Nick
DictionaryBase so that I can add items with an associated key. When I try to
serialize the object though, I get the following error: The type
BuildingsCollec tion is not supported because it implements IDictionary. Here
is my class:
Namespace BusinessLogicLa yer
<Serializable() > _
Public Class BuildingsCollec tion
Inherits DictionaryBase
Default Property Item(ByVal key As String) As Building
Get
Return Me.Dictionary.I tem(key)
End Get
Set(ByVal Value As Building)
Me.Dictionary.I tem(key) = Value
End Set
End Property
Public Sub Add(ByVal item As Building, ByVal key As String)
Dictionary.Add( key, item)
End Sub
Public Function Contains(ByVal key As String) As Boolean
Return Dictionary.Cont ains(key)
End Function
Public ReadOnly Property Keys() As ICollection
Get
Return Dictionary.Keys
End Get
End Property
Public ReadOnly Property Values() As ICollection
Get
Return Dictionary.Valu es
End Get
End Property
Public Sub Remove(ByVal key As String)
Me.Dictionary.R emove(key)
End Sub
End Class
End Namespace
Do I have to do anything special to it to allow me to serialize to XML? The
Building object seen in the class is just what I want my collection to be of
so other objects will not work. The building class will work with
serialization. In my main app I have a "Person" class defined with the
following: Private pBuildings as BuildingsCollec tion, since one person could
have more than one building.
Thanks in advance...
- Nick
Comment