Пример #1
0
        public static CheckedRet <object> Deserial(ByteList bytes)
        {
            var size = bytes.DropInt32();

            if (bytes.Count != size)
            {
                return(CheckedRet <object> .Fail());
            }
            var ret = new Trfm();

            for (int i = 0; i < 3; i++)
            {
                var _size  = bytes.DropInt32();
                var _bytes = bytes.DropRange(0, _size);
                var _obj   = Serializer.Deserialize <Vec3>(_bytes);
                if (_obj.Key == false)
                {
                    return(CheckedRet <object> .Fail());
                }
                ret.mVal [i] = _obj.Value;
            }

            // 小数点に関わるため、ハッシュチェックはしない(できない)
            return(CheckedRet <object> .Gen(true, ret));
        }
Пример #2
0
        public static CheckedRet <object> Deserial(ByteList bytes)
        {
            var size = bytes.DropInt32();

            if (bytes.Count != size)
            {
                throw new Exception("1");
                //   return CheckedRet<object>.Fail();
            }
            var ret = new Msg();

            var dic_size = bytes.DropInt32();

            for (int i = 0; i < dic_size; i++)
            {
                var k_l = bytes.DropInt32();
                var k   = Serializer.Deserialize <string>(bytes.DropRange(0, k_l));
                if (k.Key == false)
                {
                    throw new Exception("5");
                }
                var v_l = bytes.DropInt32();
                var v   = Serializer.Deserialize <string>(bytes.DropRange(0, v_l));
                if (v.Key == false)
                {
                    throw new Exception("6");
                }
                ret.Set(k.Value, v.Value);
            }

            var data_size = bytes.DropInt32();
            var h_s       = 0;

            if (data_size < 4)
            {
                h_s = bytes.DropInt32();
                if (ret.GetHashCode() != h_s)
                {
                    throw new Exception("2:" + ret.ToJson());
                }
                return((ret.GetHashCode() != h_s)
                    ? CheckedRet <object> .Fail()
                    : CheckedRet <object> .Gen(true, ret));
            }

            var data_bytes = bytes.DropRange(0, data_size);
            var obj        = Serializer.Deserialize <object>(data_bytes);

            if (obj.Key == false)
            {
                throw new Exception("3");
                //return CheckedRet<object>.Fail();
            }
            ret.mObjectData = obj.Value;

            h_s = bytes.DropInt32();
            if (ret.GetHashCode() != h_s)
            {
                throw new Exception("4");
            }

            return((ret.GetHashCode() != h_s)
                ? CheckedRet <object> .Fail()
                : CheckedRet <object> .Gen(true, ret));
        }