/// <summary> /// Parse a single field from <paramref name="input"/> and merge it /// into this set. /// </summary> /// <param name="input">The coded input stream containing the field</param> /// <returns>false if the tag is an "end group" tag, true otherwise</returns> private bool MergeFieldFrom(CodedInputStream input) { uint tag = input.LastTag; int number = WireFormat.GetTagFieldNumber(tag); switch (WireFormat.GetTagWireType(tag)) { case WireFormat.WireType.Varint: { ulong uint64 = input.ReadUInt64(); GetOrAddField(number).AddVarint(uint64); return(true); } case WireFormat.WireType.Fixed32: { uint uint32 = input.ReadFixed32(); GetOrAddField(number).AddFixed32(uint32); return(true); } case WireFormat.WireType.Fixed64: { ulong uint64 = input.ReadFixed64(); GetOrAddField(number).AddFixed64(uint64); return(true); } case WireFormat.WireType.LengthDelimited: { ByteString bytes = input.ReadBytes(); GetOrAddField(number).AddLengthDelimited(bytes); return(true); } case WireFormat.WireType.StartGroup: { uint endTag = WireFormat.MakeTag(number, WireFormat.WireType.EndGroup); UnknownFieldSet set = new UnknownFieldSet(); while (input.ReadTag() != endTag) { set.MergeFieldFrom(input); } GetOrAddField(number).AddGroup(set); return(true); } case WireFormat.WireType.EndGroup: { return(false); } default: throw InvalidProtocolBufferException.InvalidWireType(); } }
/// <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(); } }