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); }
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(); }
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(); }
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; }