Created
January 8, 2014 13:01
-
-
Save gregoryyoung/8316430 to your computer and use it in GitHub Desktop.
ouch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ArraySegment<byte> Serialize<T>(this T protoContract) | |
{ | |
using (var memory = new MemoryStream()) | |
{ | |
Serializer.Serialize(memory, protoContract); | |
var res = new ArraySegment<byte>(memory.GetBuffer(), 0, (int) memory.Length); | |
return res; | |
} | |
} | |
public static byte[] SerializeToArray<T>(this T protoContract) | |
{ | |
using (var memory = new MemoryStream()) | |
{ | |
Serializer.Serialize(memory, protoContract); | |
return memory.ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment