PivotalTrackerAPI/Util/SerializationHelper.cs
/// <summary>
/// Serializes an object of type T to an XmlDocument
/// </summary>
/// <typeparam name="T">The Type of object</typeparam>
/// <param name="t">The object to serialize</param>
Serializes an object of type T to an XmlDocument
Serializes an object of type T to an XmlDocument
public static XmlDocument SerializeToXmlDocument<T>(T t)
    {
      XmlSerializer serializer = new XmlSerializer(t.GetType());
      XmlDocument xmlDoc = new XmlDocument();
      StringBuilder sb = new StringBuilder();
      StringWriter stringWriter = new StringWriter(sb);
      try
      {
        serializer.Serialize(stringWriter, t);
      }
      finally
      {
        if (stringWriter != null)
          stringWriter.Close();
      }
      xmlDoc.LoadXml(sb.ToString());
      return xmlDoc;
    }
public static XmlDocument SerializeToXmlDocument < T > ( T t ) { XmlSerializer serializer = new XmlSerializer ( t . GetType ( ) ) ; XmlDocument xmlDoc = new XmlDocument ( ) ; StringBuilder sb = new StringBuilder ( ) ; StringWriter stringWriter = new StringWriter ( sb ) ; try { serializer . Serialize ( stringWriter , t ) ; } finally { if ( stringWriter != null ) stringWriter . Close ( ) ; } xmlDoc . LoadXml ( sb . ToString ( ) ) ; return xmlDoc ; }
Serializes an object of type T to an XmlDocument
Serializes an object of type T to an XmlDocument
t
T
The object to serialize
The object to serialize
typeparam
The Type of object
The Type of object