Beispiel #1
0
        internal MioObject ReadStruct(MProto proto, MioStruct meta)
        {
            if (meta == null)
            {
                return(null);
            }
            var struc = proto.ReadStructBegin();
            var res   = new MioObject();

            while (true)
            {
                var field = proto.ReadFieldBegin();
                if (field.Type == MType.Null)
                {
                    break;
                }
                if (!meta.Fields.ContainsKey(field.ID))
                {
                    Skip(proto, field.Type);
                    continue;
                }
                var miofield = meta.Fields[field.ID];
                if (miofield.Meta.Type != field.Type)
                {
                    Skip(proto, field.Type);
                    continue;
                }
                var obj = Read(proto, miofield.Meta);
                res.SetObject(miofield.ID, obj);
            }
            return(res);
        }
Beispiel #2
0
        internal void WriteStruct(MProto proto, MioStruct meta, MioObject data)
        {
            if (data == null)
            {
                proto.WriteFieldStop();
                return;
            }
            var struc = new MStruct();

            proto.WriteStructBegin(struc);
            foreach (var field in meta.Fields.Values)
            {
                var obj = data.GetObject(field.ID);
                if (obj == null)
                {
                    continue;
                }
                var f = new MField(string.Empty, field.Meta.Type, field.ID);
                proto.WriteFieldBegin(f);
                Write(proto, field.Meta, obj);
            }
            proto.WriteFieldStop();
        }
Beispiel #3
0
 internal void WriteStruct(MProto proto, MioStruct meta, MioObject data)
 {
     if (data == null)
     {
         proto.WriteFieldStop();
         return;
     }
     var struc = new MStruct();
     proto.WriteStructBegin(struc);
     foreach (var field in meta.Fields.Values)
     {
         var obj = data.GetObject(field.ID);
         if (obj == null)
             continue;
         var f = new MField(string.Empty, field.Meta.Type, field.ID);
         proto.WriteFieldBegin(f);
         Write(proto, field.Meta, obj);
     }
     proto.WriteFieldStop();
 }
Beispiel #4
0
 internal MioObject ReadStruct(MProto proto, MioStruct meta)
 {
     if (meta == null)
         return null;
     var struc = proto.ReadStructBegin();
     var res = new MioObject();
     while (true)
     {
         var field = proto.ReadFieldBegin();
         if (field.Type == MType.Null)
             break;
         if (!meta.Fields.ContainsKey(field.ID))
         {
             Skip(proto, field.Type);
             continue;
         }
         var miofield = meta.Fields[field.ID];
         if (miofield.Meta.Type != field.Type)
         {
             Skip(proto, field.Type);
             continue;
         }
         var obj = Read(proto, miofield.Meta);
         res.SetObject(miofield.ID, obj);
     }
     return res;
 }