Пример #1
0
 private void IgnoreByte(SprotoStream reader, UInt32 size)
 {
     for (UInt32 i = 0; i < size; i++)
     {
         reader.ReadByte();
     }
 }
Пример #2
0
        private List <Int64> DecodeIntegerList(SprotoStream reader)
        {
            List <Int64> list = new List <Int64>();
            UInt32       size = this.ReadUInt32(reader);

            if (size == 0)
            {
                return(list);
            }
            UInt32 sizeof_integer = (UInt32)reader.ReadByte();

            size--;
            for (; size > 0; size = size - sizeof_integer)
            {
                Int64 integer;
                if (sizeof_integer == sizeof(UInt32))
                {
                    Int32 number = (Int32)this.ReadUInt32(reader);
                    integer = (Int64)number;
                }
                else
                {
                    integer = (Int64)this.ReadUInt64(reader);
                }
                list.Add(integer);
            }
            if (size != 0)
            {
                SprotoHelper.Error("[SprotoCodec.DecodeIntegerList] fail");
            }
            return(list);
        }
Пример #3
0
        private UInt64 ReadUInt64(SprotoStream reader)
        {
            UInt64 number;
            int    len = 8;

            byte[] bytes = new byte[len];
            for (int i = 0; i < len; i++)
            {
                bytes[i] = reader.ReadByte();
            }
            number = BitConverter.ToUInt64(bytes, 0);
            //Console.WriteLine("ReadUInt64: {0}",number);
            return(number);
        }
Пример #4
0
        private UInt16 ReadUInt16(SprotoStream reader)
        {
            // little-endian
            UInt16 number;
            int    len = 2;

            byte[] bytes = new byte[len];
            for (int i = 0; i < len; i++)
            {
                bytes[i] = reader.ReadByte();
            }
            number = BitConverter.ToUInt16(bytes, 0);
            //Console.WriteLine("ReadUInt16: {0}",number);
            return(number);
        }
Пример #5
0
        private bool DecodeBoolean(SprotoStream reader)
        {
            byte b = reader.ReadByte();

            return(Convert.ToBoolean(b));
        }