Reputation: 4122
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 abstract class SpecialList<T> : List<T>
{
//Other methods here
}
public class Cache : SpecialList<CacheEntry>
{
[XmlElementAttribute("CustomName")]
public List<CacheEntry> Entries {
get { return ???; }
set { ??? = value; }
}
}
Is this actually possible without either overriding the base class methods, writing custom serialization, or implementing IXmlSerializable?
I'm expecting to produce output XML something like this:
<cache>
<customname></customname>
<customname></customname>
</cache>
Upvotes: 1
Views: 93
Reputation: 62
If you want to write elements with custom element names, you need to override the base class properties .. or write new methods to encapsulate the base class properties.
Upvotes: 2