Exemple #1
0
 /// <summary>
 /// Deeps the clone.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="self">The self.</param>
 /// <param name="obj">The object.</param>
 /// <returns>T.</returns>
 public static T DeepClone <T>(this SerializerBase self, T obj)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         self.Serialize(obj, ms);
         ms.Seek(0, SeekOrigin.Begin);
         return(self.Deserialize <T>(ms));
     }
 }
Exemple #2
0
 /// <summary>
 /// Deserializes the specified stream.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="self">The self.</param>
 /// <param name="stream">The stream.</param>
 /// <returns>T.</returns>
 public static T Deserialize <T>(this SerializerBase self, Stream stream)
 {
     return((T)self.Deserialize(stream, typeof(T)));
 }