Exemple #1
0
 public static object Deserialize(Type type, byte[] data, bool suppressErrors = true)
 {
     try
     {
         var s = new Wr.Serializer(new Wr.SerializerOptions());
         using (var ms = new MemoryStream(data))
         {
             return(s.Deserialize(ms));
         }
     }
     catch (Exception e)
     {
         if (!suppressErrors)
         {
             ExceptionDispatchInfo.Capture(e).Throw();
         }
         return(null);
     }
 }
Exemple #2
0
 public static T Deserialize <T>(byte[] data, bool suppressErrors = true)
 {
     try
     {
         var s = new Wr.Serializer(new Wr.SerializerOptions());
         using (var ms = new MemoryStream(data))
         {
             return(s.Deserialize <T>(ms));
         }
     }
     catch (Exception e)
     {
         if (!suppressErrors)
         {
             ExceptionDispatchInfo.Capture(e).Throw();
         }
         return(default(T));
     }
 }