'IXmlSerializable with Interface
I'm having a list i'm trying deserialize. i not own IBaseIndicator object but it implement IXmlSerializable.
I just need 2 things to control serialization 1- overide root elementName 2-being able set the type as root attribut so i retrieve the type
for now i have this overide
public void WriteXml(XmlWriter writer)
{
foreach (IBaseIndicator indicator in Indicators)
{
XmlRootAttribute xmlRootAttribute = new XmlRootAttribute();
xmlRootAttribute.ElementName = nameof(IBaseIndicator);
//how to insert this kind attribute -> writer.WriteAttributeString("AssemblyQualifiedName", this.GetType().AssemblyQualifiedName);
XmlSerializer xmlSerializer = new XmlSerializer(indicator.GetType(),xmlRootAttribute);
xmlSerializer.Serialize(writer, indicator);
}
}
this just overide rootname but i like to get this with AssemblyQualifiedName attribute is it even possible ?
<IBaseIndicator AssemblyQualifiedName="NosIndicator.Ohlc.Ohlc, NosIndicators, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
