Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }