Is there a way to override the XML DateTime serialization in Servicestack.Net like we can do with JSON:
JsConfig<DateTime>.SerializeFn = date => new DateTime(date.Ticks, DateTimeKind.Local).ToString("dd.MM.yyyy HH:mm:ss");
I want to do the same thing for all XML DateTimes.
Edit:
I just found out I can hook into the XML serialization with this:
this.ContentTypeFilters.Register("application/xml", SerializeXmlToStream, DeserializeXmlFromStream);
public static void SerializeXmlToStream(IRequestContext requestContext, object response, Stream stream)
{
using (var sw = new StreamWriter(stream))
{
sw.Write(response.ToXml());
}
}
This returns the same XML as without this hook. If someone has any idea how I can change the serialiazation of DateTime to a custom format with this or any other global way please let me know.