private static int DeserializeInteger(Protocol16Stream input)
        {
            var buffer = _byteBuffer.Value;

            input.Read(buffer, 0, sizeof(int));

            return(buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3]);
        }
        public static short DeserializeShort(Protocol16Stream input)
        {
            var buffer = _byteBuffer.Value;

            input.Read(buffer, 0, sizeof(short));

            return((short)(buffer[0] << 8 | buffer[1]));
        }
        private static byte[] DeserializeByteArray(Protocol16Stream input)
        {
            int arraySize = DeserializeInteger(input);

            var buffer = new byte[arraySize];

            input.Read(buffer, 0, arraySize);

            return(buffer);
        }
        private static long DeserializeLong(Protocol16Stream input)
        {
            var buffer = _byteBuffer.Value;

            input.Read(buffer, 0, sizeof(long));

            if (BitConverter.IsLittleEndian)
            {
                return((long)buffer[0] << 56 | (long)buffer[1] << 48 | (long)buffer[2] << 40 | (long)buffer[3] << 32 | (long)buffer[4] << 24 | (long)buffer[5] << 16 | (long)buffer[6] << 8 | buffer[7]);
            }

            return(BitConverter.ToInt64(buffer, 0));
        }
        private static string DeserializeString(Protocol16Stream input)
        {
            int stringSize = DeserializeShort(input);

            if (stringSize == 0)
            {
                return(string.Empty);
            }

            var buffer = new byte[stringSize];

            input.Read(buffer, 0, stringSize);

            return(Encoding.UTF8.GetString(buffer, 0, stringSize));
        }
        private static float DeserializeFloat(Protocol16Stream input)
        {
            var buffer = _byteBuffer.Value;

            input.Read(buffer, 0, sizeof(float));

            if (BitConverter.IsLittleEndian)
            {
                byte b0 = buffer[0];
                byte b1 = buffer[1];
                buffer[0] = buffer[3];
                buffer[1] = buffer[2];
                buffer[2] = b1;
                buffer[3] = b0;
            }

            return(BitConverter.ToSingle(buffer, 0));
        }
        private static double DeserializeDouble(Protocol16Stream input)
        {
            var buffer = _byteBuffer.Value;

            input.Read(buffer, 0, sizeof(double));

            if (BitConverter.IsLittleEndian)
            {
                byte b0 = buffer[0];
                byte b1 = buffer[1];
                byte b2 = buffer[2];
                byte b3 = buffer[3];
                buffer[0] = buffer[7];
                buffer[1] = buffer[6];
                buffer[2] = buffer[5];
                buffer[3] = buffer[4];
                buffer[4] = b3;
                buffer[5] = b2;
                buffer[6] = b1;
                buffer[7] = b0;
            }

            return(BitConverter.ToDouble(buffer, 0));
        }