Пример #1
0
        public byte[] ReadBytesFlipped(int count)
        {
            CheckLength(count);
            var temp = new byte[count];

            Buffer.BlockCopy(_buffer, _index, temp, 0, count);
            EndianConvert.EndianConverter(temp);
            _index += count;
            return(temp);
        }
Пример #2
0
        public unsafe short ReadShort()
        {
            CheckLength(2);

            short value;

            fixed(byte *ptr = _buffer)
            {
                value = *(short *)(ptr + _index);
            }

            value = BitConverter.ToInt16(EndianConvert.EndianConverter(BitConverter.GetBytes(value)), 0);

            _index += 2;

            return(value);
        }
Пример #3
0
        public unsafe long ReadLong()
        {
            CheckLength(8);

            long value;

            fixed(byte *ptr = _buffer)
            {
                value = *(long *)(ptr + _index);
            }

            value = BitConverter.ToInt64(EndianConvert.EndianConverter(BitConverter.GetBytes(value)), 0);

            _index += 8;

            return(value);
        }
Пример #4
0
        public unsafe int ReadInt()
        {
            CheckLength(4);

            int value;

            fixed(byte *ptr = _buffer)
            {
                value = *(int *)(ptr + _index);
            }

            value = BitConverter.ToInt32(EndianConvert.EndianConverter(BitConverter.GetBytes(value)), 0);

            _index += 4;

            return(value);
        }
Пример #5
0
        public void WriteShort(short value = 0)
        {
            ThrowIfDisposed();

            WriteBytes(EndianConvert.EndianConverter(BitConverter.GetBytes(value)));
        }
Пример #6
0
        public void WriteLong(long value = 0)
        {
            ThrowIfDisposed();

            WriteBytes(EndianConvert.EndianConverter(BitConverter.GetBytes(value)));
        }