2 using System.Collections.Generic;
5 using System.Xml.Serialization;
9 public static class ObjectExtensions
17 public static string XmlSerialize<T>(
this T ObjectToSerialize)
19 Type RealType = ObjectToSerialize.GetType();
22 using (MemoryStream ms =
new MemoryStream())
25 XmlSerializerNamespaces Namespaces =
new XmlSerializerNamespaces();
26 Namespaces.Add(
string.Empty,
string.Empty);
28 new XmlSerializer(RealType).Serialize(ms, ObjectToSerialize,Namespaces);
30 using (StreamReader sr =
new StreamReader(ms, Encoding.Default))