Custom XmlSerializer for some types not working in ASP.NET Web API 2.1 -
asp.net web api not invoke xmlserializer registered mytype below -
when place breakpoints in either of myserializer method not heat.
globalconfiguration.configuration.formatters.xmlformatter.usexmlserializer = true; globalconfiguration.configuration.formatters.xmlformatter.removeserializer(typeof(mytype)); globalconfiguration.configuration.formatters.xmlformatter.setserializer<mytype>(new myserializer());
myserializer implemented below -
public class myserializer : system.xml.serialization.xmlserializer { public override bool candeserialize(system.xml.xmlreader xmlreader) { return base.candeserialize(xmlreader); } protected override system.xml.serialization.xmlserializationreader createreader() { return base.createreader(); } protected override system.xml.serialization.xmlserializationwriter createwriter() { return base.createwriter(); } protected override object deserialize(system.xml.serialization.xmlserializationreader reader) { return base.deserialize(reader); } protected override void serialize(object o, system.xml.serialization.xmlserializationwriter writer) { try { base.serialize(o, writer); } catch (exception ex) { } } }
Comments
Post a Comment