public static byte[] Serialize <T>(T message) { var sizeOfMessage = SizeMapperManager.SizeOfMessage(message, true); var fbw = new FastBinaryWriter(sizeOfMessage); fbw.CreateContext( ctx => Serialize(message, ctx)); return(fbw.Buffer); }
public static byte[] Serialize <T>(IEnumerable <T> messages) { var sizeOfMessage = SizeMapperManager.SizeOfMessage(messages, true); var fbw = new FastBinaryWriter(sizeOfMessage); fbw.CreateContext( ctx => { foreach (var message in messages) { Serialize(message, ctx); } }); return(fbw.Buffer); }