Override any XmlConverter class like Newtonsoft's JsonConverter [C#]

时间:2016-12-02 04:51:24

标签: c# xml serialization

How can I implement XML similar to what I did with Json below:

I overridden JsonConverter class of Newtonsoft

public class DecimalFormatConverter : JsonConverter 
{ 
    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 
    { 
        writer.WriteValue(string.Format("{0:N2}", value)); 
    } 
}

And add attribute for Total:

JsonConverter(typeof(DecimalFormatConverter))] 
public decimal Total { get; set; }

Also, Where can I find a similar XMLConverter class to reuse? Newtonsoft only has JsonConverter

0 个答案:

没有答案