Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
0
 public static T FromProtoBuf <T>(this Stream stream)
 {
     return((T)ProtoBufFormat.Deserialize2 <T>(typeof(T), stream));;
 }