Beispiel #1
0
        public void ReadExternal(IDataInput input)
        {
            int    size = input.ReadByte() << 24 | input.ReadByte() << 16 | input.ReadByte() << 8 | input.ReadByte();
            string json = Encoding.UTF8.GetString(input.ReadBytes(size));

            Data = JsonConvert.DeserializeObject <ClientSystemStatesNotificationDecoded>(json);
        }
Beispiel #2
0
        public static char ReadUtf8Char(IDataInput input, byte firstByte)
        {
            var b = firstByte & 0xFF;

            switch (b >> 4)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                return((char)b);

            case 12:
            case 13:
                var first  = (b & 0x1F) << 6;
                var second = input.ReadByte() & 0x3F;
                return((char)(first | second));

            case 14:
                var first2  = (b & 0x0F) << 12;
                var second2 = (input.ReadByte() & 0x3F) << 6;
                var third2  = input.ReadByte() & 0x3F;
                return((char)(first2 | second2 | third2));

            default:
                throw new InvalidDataException("Malformed byte sequence");
            }
        }
        public static int readU29(IDataInput bytes)
        {
            int value;

            // Each byte must be treated as unsigned
            int b = bytes.ReadByte() & 0xFF;

            if (b < 128)
            {
                return(b);
            }

            value = (b & 0x7F) << 7;
            b     = bytes.ReadByte() & 0xFF;

            if (b < 128)
            {
                return(value | b);
            }

            value = (value | (b & 0x7F)) << 7;
            b     = bytes.ReadByte() & 0xFF;

            if (b < 128)
            {
                return(value | b);
            }

            value = (value | (b & 0x7F)) << 8;
            b     = bytes.ReadByte() & 0xFF;

            return(value | b);
        }
        public void ReadExternal(IDataInput input)
        {
            int size = input.ReadByte() << 24 | input.ReadByte() << 16 | input.ReadByte() << 8 | input.ReadByte();
            string json=Encoding.UTF8.GetString(input.ReadBytes(size));

            Dictionary<string,object> d=Serializer.Deserialize<Dictionary<string,object>>(json);
            foreach (var kv in d)
            {
                this[kv.Key] = kv.Value;
            }
        }
Beispiel #5
0
        public void ReadExternal(IDataInput input)
        {
            int    size = input.ReadByte() << 24 | input.ReadByte() << 16 | input.ReadByte() << 8 | input.ReadByte();
            string json = Encoding.UTF8.GetString(input.ReadBytes(size));

            Dictionary <string, object> d = Serializer.Deserialize <Dictionary <string, object> >(json);

            foreach (var kv in d)
            {
                this[kv.Key] = kv.Value;
            }
        }
Beispiel #6
0
        protected List <byte> ReadFlags(IDataInput input)
        {
            List <byte> byteList = new List <byte>();
            byte        num;

            do
            {
                num = input.ReadByte();
                byteList.Add(num);
            }while (((int)num & 128) != 0);
            return(byteList);
        }
Beispiel #7
0
        protected List <byte> ReadFlags(IDataInput input)
        {
            var  flags = new List <byte>();
            byte flag;

            do
            {
                flag = input.ReadByte();
                flags.Add(flag);
            } while ((flag & 0x80) != 0);

            return(flags);
        }
 public static char ReadUtf8Char(IDataInput input, byte firstByte)
 {
     var b = firstByte & 0xFF;
     switch (b >> 4)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
             return (char) b;
         case 12:
         case 13:
             var first = (b & 0x1F) << 6;
             var second = input.ReadByte() & 0x3F;
             return (char) (first | second);
         case 14:
             var first2 = (b & 0x0F) << 12;
             var second2 = (input.ReadByte() & 0x3F) << 6;
             var third2 = input.ReadByte() & 0x3F;
             return (char) (first2 | second2 | third2);
         default:
             throw new InvalidDataException("Malformed byte sequence");
     }
 }
        PartFlags[] ReadFlags(IDataInput input)
        {
            IList<PartFlags> flags = new List<PartFlags>();

            while (true)
            {
                PartFlags flag = (PartFlags)input.ReadByte();
                flags.Add(flag);

                if ((flag & PartFlags.HAS_NEXT_FLAG) == 0)
                    break;
            }

            return flags.ToArray();
        }
        protected List<byte> ReadFlags(IDataInput input)
        {
            List<byte> flags = new List<byte>();
            byte flag;
            do
            {
                flag = input.ReadByte();
                flags.Add(flag);
            } while ((flag & 0x80) != 0);

            return flags;
        }
Beispiel #11
0
 /// <summary>
 /// 读取一个带符号 8 位数字.
 /// </summary>
 /// <param name="input">输入流对象.</param>
 /// <returns>对应的数据.</returns>
 public static sbyte ReadByte(IDataInput input)
 {
     return(input.ReadByte());
 }