/// <summary> /// Reads an embedded group field from the stream. /// </summary> public void ReadGroup(IMessage builder) { ParseContext.Initialize(this, out ParseContext ctx); try { ParsingPrimitivesMessages.ReadGroup(ref ctx, builder); } finally { ctx.CopyStateTo(this); } }
/// <summary> /// Parse a single field from <paramref name="ctx"/> and merge it /// into this set. /// </summary> /// <param name="ctx">The parse context from which to read the field</param> /// <returns>false if the tag is an "end group" tag, true otherwise</returns> private bool MergeFieldFrom(ref ParseContext ctx) { uint tag = ctx.LastTag; int number = WireFormat.GetTagFieldNumber(tag); switch (WireFormat.GetTagWireType(tag)) { case WireFormat.WireType.Varint: { ulong uint64 = ctx.ReadUInt64(); GetOrAddField(number).AddVarint(uint64); return(true); } case WireFormat.WireType.Fixed32: { uint uint32 = ctx.ReadFixed32(); GetOrAddField(number).AddFixed32(uint32); return(true); } case WireFormat.WireType.Fixed64: { ulong uint64 = ctx.ReadFixed64(); GetOrAddField(number).AddFixed64(uint64); return(true); } case WireFormat.WireType.LengthDelimited: { ByteString bytes = ctx.ReadBytes(); GetOrAddField(number).AddLengthDelimited(bytes); return(true); } case WireFormat.WireType.StartGroup: { UnknownFieldSet set = new UnknownFieldSet(); ParsingPrimitivesMessages.ReadGroup(ref ctx, number, set); GetOrAddField(number).AddGroup(set); return(true); } case WireFormat.WireType.EndGroup: { return(false); } default: throw InvalidProtocolBufferException.InvalidWireType(); } }
public void ReadGroup(IMessage message) { ParsingPrimitivesMessages.ReadGroup(ref this, message); }