Esempio n. 1
0
        public void Write(byte[] value, int size)
        {
#if USE_MESSAGE_PACk
            _serializer.Serialize(value);
#else
            byte[] bytes = ByteOrderConverter.GetBytes(value, size);
            _stream.Write(bytes, 0, size);
#endif
        }
Esempio n. 2
0
        public void Write(ulong value)
        {
#if USE_MESSAGE_PACK
            _serializer.Serialize(value);
#else
            byte[] bytes = ByteOrderConverter.GetBytes(value);
            _stream.Write(bytes, 0, bytes.Length);
#endif
        }
Esempio n. 3
0
        public ulong ReadUInt64()
        {
#if USE_MESSAGE_PACK
            return((ulong)_deserializer.Deserialize());
#else
            _stream.Read(_tmpBuffer, 0, sizeof(ulong));
            return(ByteOrderConverter.ToUInt64(_tmpBuffer));
#endif
        }
Esempio n. 4
0
        public bool ReadBoolean()
        {
#if USE_MESSAGE_PACK
            return((bool)_deserializer.Deserialize());
#else
            _stream.Read(_tmpBuffer, 0, sizeof(bool));
            return(ByteOrderConverter.ToBoolean(_tmpBuffer));
#endif
        }
Esempio n. 5
0
        public int ReadInt32()
        {
#if USE_MESSAGE_PACK
            return((int)_deserializer.Deserialize());
#else
            _stream.Read(_tmpBuffer, 0, sizeof(int));
            return(ByteOrderConverter.ToInt32(_tmpBuffer));
#endif
        }
Esempio n. 6
0
        public double ReadDouble()
        {
#if USE_MESSAGE_PACK
            return((double)_deserializer.Deserialize());
#else
            _stream.Read(_tmpBuffer, 0, sizeof(double));
            return(ByteOrderConverter.ToDouble(_tmpBuffer));
#endif
        }
Esempio n. 7
0
        public float ReadSingle()
        {
#if USE_MESSAGE_PACK
            return((float)_deserializer.Deserialize());
#else
            _stream.Read(_tmpBuffer, 0, sizeof(float));
            return(ByteOrderConverter.ToSingle(_tmpBuffer));
#endif
        }
Esempio n. 8
0
        public string ReadString(int size)
        {
#if USE_MESSAGE_PACK
            return((string)_deserializer.Deserialize());
#else
            if (size > _tmpBuffer.Length)
            {
                _tmpBuffer = new byte[size];
            }
            _stream.Read(_tmpBuffer, 0, sizeof(byte) * size);
            return(ByteOrderConverter.ToString(_tmpBuffer, size));
#endif
        }
Esempio n. 9
0
        public void Write(string value, int size)
        {
#if USE_MESSAGE_PACK
            _serializer.Serialize(value);
#else
            byte[] bytes = ByteOrderConverter.GetBytes(value);
            if (size > _tmpBuffer.Length)
            {
                _tmpBuffer = new byte[size];
            }
            bytes.CopyTo(_tmpBuffer, 0);
            _stream.Write(_tmpBuffer, 0, sizeof(byte) * size);
#endif
        }
Esempio n. 10
0
        public string ReadString()
        {
#if USE_MESSAGE_PACK
            return((string)_deserializer.Deserialize());
#else
            ushort length = ReadUInt16();
            if (length > _tmpBuffer.Length)
            {
                _tmpBuffer = new byte[length];
            }
            _stream.Read(_tmpBuffer, 0, sizeof(byte) * length);
            return(ByteOrderConverter.ToString(_tmpBuffer, length));
#endif
        }
Esempio n. 11
0
        public byte[] ReadBytes(int size)
        {
#if USE_MESSAGE_PACK
            return((byte[])_deserializer.Deserialize());
#else
            if (size > _tmpBuffer.Length)
            {
                _tmpBuffer = new byte[size];
            }
            _stream.Read(_tmpBuffer, 0, sizeof(byte) * size);
            byte[] bytes = new byte[size];
            Array.Copy(ByteOrderConverter.ToBytes(_tmpBuffer, size), bytes, size);
            return(bytes);
#endif
        }