Getting Property's Custom Attributes during Serialization

141 views Asked by At

I have a custom Dictionary that implements IXmlSerializable and i'm trying to create a custom attribute that can be applied to properties like XmlElementAttribute can :

    <XmlElement>
    Property Cake As Bread

A new XmlDictionaryAttribute, like this :

    <XmlDictionary(Root:="IDs", Item:="ID", Key:="Key", Value:="Value", KeyIsAttribute:=True, ValueIsAttribute:=True)>
    Property IDs As New Dictionary(Of String, String)

To give me alot more flexibility in how i want them Serialized/Deserialized

The Problem is that i don't know how to get the IDs property Dictionary during Serialization without specifying the parent class directly

IXmlSerializable's ReadXml looks like this :

    Public Sub ReadXml(Reader As System.Xml.XmlReader) Implements IXmlSerializable.ReadXml

Which doesn't seem to give any context to the parent class owning the Dictionary property.

How would i get the Attribute values during serialization class-independent like XmlElementAttribute already does it?

0

There are 0 answers