Example #1
0
 public static T FromProtoBuf <T>(this byte[] bytes)
 {
     using (var ms = new MemoryStream(bytes))
     {
         var obj = (T)ProtoBufFormat.Deserialize2 <T>(typeof(T), ms);
         return(obj);
     }
 }
Example #2
0
 public static byte[] ToProtoBuf <T>(this T obj)
 {
     using (var ms = new MemoryStream())
     {
         ProtoBufFormat.Serialize2(obj, ms);
         var bytes = ms.ToArray();
         return(bytes);
     }
 }
Example #3
0
 public static T FromProtoBuf <T>(this Stream stream)
 {
     return((T)ProtoBufFormat.Deserialize2 <T>(typeof(T), stream));;
 }