public void Unmarshal(IProtoStruct s) { while (SpaceLeft > 0) { var tag = ReadVarint32(); int fieldNumber = -1; WireFormat.WireType type = WireFormat.WireType.None; WireFormat.ParseWireTag(tag, ref fieldNumber, ref type); if (s.Unmarshal(this, fieldNumber, type)) { SkipField(type); } } }
public static int SizeStruct(int fieldIndex, IProtoStruct value) { if (value == null) { return(0); } var size = value.GetSize(); if (size == 0) { return(0); } return(GetVarint32Size(WireFormat.MakeTag(fieldIndex, WireFormat.WireType.Varint)) + GetVarint32Size((uint)size) + size); }
public void WriteStruct(int fieldIndex, IProtoStruct s) { if (s == null) { return; } var size = s.GetSize(); if (size == 0) { return; } WriteTag(fieldIndex, WireFormat.WireType.Bytes); WriteVarint32((uint)size); s.Marshal(this); }
public void Marshal(IProtoStruct s) { s.Marshal(this); }