If I have a base class that inherits from a generic list, and the derived class needs to be serialized with a custom name for the list entries how can I enter the correct serializartion attributes and/or refer to the base list?
Public MustInherit Class SpecialList(Of T)
Inherits List(Of T)
'Other methods here
End Class
Public Class Cache
Inherits SpecialList(Of CacheEntry)
<XmlElementAttribute("CustomName")> _
Public Property Entries() As List(Of CacheEntry)
Get
Return ???
End Get
Set(value As List(Of CacheEntry))
??? = value
End Set
End Property
End Class
Is this actually possible without either overriding the base class methods, writing custom serialization, or implementing IXmlSerializable?
I’m expecting to get output XML something like this:
<cache>
<customname></customname>
<customname></customname>
</cache>
Add an
XmlRootAttributetoCacheEntry:As a side question, if
Cacheinherits fromList(throughSpecialList) then why do you have aEntriesproperty that’s also aList?