Ejemplo n.º 1
0
        public void Serialize(ref byte[] buffer, ref int offset, byte[] ar)
        {
            if (ar == null)
            {
                SerializerBinary.WriteUInt32Bias(ref buffer, ref offset, -1, 1);
                return;
            }

            var len = ar.Length;

            // Ensure we have enough space for the worst-case VarInt plus the byte array itself
            SerializerBinary.EnsureCapacity(ref buffer, offset, 5 + len);

            // Write the length, no need to check the capacity (we did that here)
            SerializerBinary.WriteUInt32BiasNoCheck(ref buffer, ref offset, len, 1);

            // Blit the array
            System.Array.Copy(ar, 0, buffer, offset, len);
            offset += len;
        }