I'm trying to add some hints to the XmlSerializor so it can serialize/deserialize interfaces. I can't add the XmlIncludeAttribute as a decoration on the class, in stead I want to pass in serialization overrides to the XmlSerializor:
var _xs = new XmlSerializer(typeof(Model.ISession), SerializationOverrides());
The SerializationOverrides()
looks like this:
private static XmlAttributeOverrides SerializationOverrides()
{
var overrides = new XmlAttributeOverrides();
overrides.Add(typeof(Model.ISession), XmlInclude(typeof(Model.Session)));
return overrides;
}
So far, so good. The XmlInclude(...)
method creates a new XmlAttributes object, but I can't figure out how to add the XmlIncludeAttribute attribute.
private static XmlAttributes XmlInclude(Type type)
{
var attrs = new XmlAttributes();
attrs....Add(new XmlIncludeAttribute(type)); // Add how?????
return attrs;
}
Suggestions?