예제 #1
0
        public static byte[] PackMsgToArray <T>(ref T msg, int msgSize, WritePropsDeleg <T> writeProps)
            where T : struct
        {
            using PooledBuffer slice = PooledBuffer.Get(msgSize);
            int index = 0;

            writeProps(ref msg, slice.Data, ref index);
            return(slice.ToArray());
        }
예제 #2
0
        public static PooledBuffer PackMsgToBuffer <T>(ref T msg, int msgSize, WritePropsDeleg <T> writeProps)
            where T : struct
        {
            PooledBuffer data  = PooledBuffer.Get(msgSize);
            int          index = 0;

            writeProps(ref msg, data.Data, ref index);
            return(data);
        }
예제 #3
0
        public static void PackMsgToStream <T>(ref T msg, Stream destinationStream, int msgSize, WritePropsDeleg <T> writeProps)
            where T : struct
        {
            using PooledBuffer slice = PooledBuffer.Get(msgSize);
            int index = 0;

            writeProps(ref msg, slice.Data, ref index);
            slice.WriteInto(destinationStream);
        }