Is there an easy way to get DataContractSerializer to spit out formatted XML rather then one long string? I don\'t want to change the tags or content in any way, just have it ad
public static string SerializeEntity(T source)
{
using (MemoryStream ms = new MemoryStream())
{
NetDataContractSerializer serializer = new NetDataContractSerializer();
serializer.Serialize(ms, source);
return System.Text.Encoding.ASCII.GetString(ms.ToArray());
}
}
public static T DeSerializeEntity(string xml)
{
using (MemoryStream ms = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(xml)))
{
NetDataContractSerializer serializer = new NetDataContractSerializer();
return (T)serializer.Deserialize(ms);
}
}