src/Foundation/Infrastructure/Gimela.Infrastructure.Serialization/FileSerializer.cs
/// <summary>
/// XmlSerializerClone is typically used when copies of an Xml serializable object are needed to prevent modification
/// </summary>
/// <typeparam name="T">Data type of object being cloned</typeparam>
/// <param name="original">Original object being cloned</param>
/// <returns>Duplicate copy of original object</returns>
XmlSerializerClone is typically used when copies of an Xml serializable object are needed to prevent modification
XmlSerializerClone is typically used when copies of an Xml serializable object are needed to prevent modification
public static T XmlSerializerClone<T>(T original)
    {
      T target = default(T);
      XmlSerializer xs = new XmlSerializer(typeof(T));
      using (MemoryStream ms = new MemoryStream())
      {
        xs.Serialize(ms, original);
        ms.Seek(0, SeekOrigin.Begin);
        target = (T)xs.Deserialize(ms);
      }
      return target;
    }
public static T XmlSerializerClone < T > ( T original ) { T target = default ( T ) ; XmlSerializer xs = new XmlSerializer ( typeof ( T ) ) ; using ( MemoryStream ms = new MemoryStream ( ) ) { xs . Serialize ( ms , original ) ; ms . Seek ( 0 , SeekOrigin . Begin ) ; target = ( T ) xs . Deserialize ( ms ) ; } return target ; }
XmlSerializerClone is typically used when copies of an Xml serializable object are needed to prevent modification
XmlSerializerClone is typically used when copies of an Xml serializable object are needed to prevent modification
Duplicate copy of original object
Duplicate copy of original object
original
T
Original object being cloned
Original object being cloned
typeparam
Data type of object being cloned
Data type of object being cloned