Is there any way to configure the default XmlWriter used by WCF service with DataContractSerializer when serializing data?
Out of the box WCF service using DataContractSerializer is losing the new lines (\r\n).
[Edit: I apologize for the confusion. Out of the box WCF DOES NOT lose the new lines.]
I am able to make XmlWriter encode the new lines to 
by using XmlWriterSettings (NewLineHandling.Entitize), but I want to make WCF behave the same way when serialize my object.
public string Serialize<T>(T object)
{
var serializer = new DataContractSerializer(typeof(T));
using (var stringWriter = new StringWriter())
{
var settings = new XmlWriterSettings { NewLineHandling = NewLineHandling.Entitize };
using (var xmlWriter = XmlWriter.Create(stringWriter, settings))
{
serializer.WriteObject(xmlWriter, object);
string xml = stringWriter.ToString();
return xml;
}
}
}