示例#1
0
        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);
        }
示例#2
0
        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);
        }