Google.Protobuf.UninterpretedOption.DeserializeLength C# (CSharp) Method

DeserializeLength() public static method

Read the given number of bytes from the stream and deserialze it into the instance.
public static DeserializeLength ( Stream stream, int length, Google instance ) : Google.Protobuf.UninterpretedOption
stream Stream
length int
instance Google
return Google.Protobuf.UninterpretedOption
        public static Google.Protobuf.UninterpretedOption DeserializeLength(Stream stream, int length, Google.Protobuf.UninterpretedOption instance)
        {
            var br = new BinaryReader(stream);
            if (instance.Name == null)
                instance.Name = new List<Google.Protobuf.UninterpretedOption.NamePart>();
            long limit = stream.Position + length;
            while (true)
            {
                if (stream.Position >= limit)
                {
                    if (stream.Position == limit)
                        break;
                    else
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Read past max limit");
                }
                int keyByte = stream.ReadByte();
                if (keyByte == -1)
                    throw new System.IO.EndOfStreamException();
                // Optimized reading of known fields with field ID < 16
                switch (keyByte)
                {
                    // Field 2 LengthDelimited
                    case 18:
                        // repeated
                        instance.Name.Add(Google.Protobuf.UninterpretedOption.NamePart.DeserializeLengthDelimited(stream));
                        continue;
                    // Field 3 LengthDelimited
                    case 26:
                        instance.IdentifierValue = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                    // Field 4 Varint
                    case 32:
                        instance.PositiveIntValue = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 5 Varint
                    case 40:
                        instance.NegativeIntValue = (long)global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadUInt64(stream);
                        continue;
                    // Field 6 Fixed64
                    case 49:
                        instance.DoubleValue = br.ReadDouble();
                        continue;
                    // Field 7 LengthDelimited
                    case 58:
                        instance.StringValue = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadBytes(stream);
                        continue;
                    // Field 8 LengthDelimited
                    case 66:
                        instance.AggregateValue = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadString(stream);
                        continue;
                }

                var key = global::SilentOrbit.ProtocolBuffers.ProtocolParser.ReadKey((byte)keyByte, stream);

                // Reading field ID > 16 and unknown field ID/wire type combinations
                switch (key.Field)
                {
                    case 0:
                        throw new global::SilentOrbit.ProtocolBuffers.ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                    default:
                        global::SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(stream, key);
                        break;
                }
            }

            return instance;
        }

Same methods

UninterpretedOption::DeserializeLength ( Stream stream, int length ) : UninterpretedOption