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); } }
public static byte[] ToProtoBuf <T>(this T obj) { using (var ms = new MemoryStream()) { ProtoBufFormat.Serialize2(obj, ms); var bytes = ms.ToArray(); return(bytes); } }
public static T FromProtoBuf <T>(this Stream stream) { return((T)ProtoBufFormat.Deserialize2 <T>(typeof(T), stream));; }