internal static void MergeDelimitedFrom(this IMessage message, Stream input, bool discardUnknownFields, ExtensionRegistry registry)
        {
            ProtoPreconditions.CheckNotNull(message, "message");
            ProtoPreconditions.CheckNotNull(input, "input");
            int    size          = (int)CodedInputStream.ReadRawVarint32(input);
            Stream limitedStream = new LimitedInputStream(input, size);

            MergeFrom(message, limitedStream, discardUnknownFields, registry);
        }
        internal static void MergeFrom(this IMessage message, ByteString data, bool discardUnknownFields, ExtensionRegistry registry)
        {
            ProtoPreconditions.CheckNotNull(message, "message");
            ProtoPreconditions.CheckNotNull(data, "data");
            CodedInputStream input = data.CreateCodedInput();

            input.DiscardUnknownFields = discardUnknownFields;
            input.ExtensionRegistry    = registry;
            message.MergeFrom(input);
            input.CheckReadEndOfStreamTag();
        }
        internal static void MergeFrom(this IMessage message, Stream input, bool discardUnknownFields, ExtensionRegistry registry)
        {
            ProtoPreconditions.CheckNotNull(message, "message");
            ProtoPreconditions.CheckNotNull(input, "input");
            CodedInputStream codedInput = new CodedInputStream(input);

            codedInput.DiscardUnknownFields = discardUnknownFields;
            codedInput.ExtensionRegistry    = registry;
            message.MergeFrom(codedInput);
            codedInput.CheckReadEndOfStreamTag();
        }
        internal static void MergeFrom(this IMessage message, byte[] data, int offset, int length, bool discardUnknownFields, ExtensionRegistry registry)
        {
            ProtoPreconditions.CheckNotNull(message, "message");
            ProtoPreconditions.CheckNotNull(data, "data");
            CodedInputStream input = new CodedInputStream(data, offset, length);

            input.DiscardUnknownFields = discardUnknownFields;
            input.ExtensionRegistry    = registry;
            message.MergeFrom(input);
            input.CheckReadEndOfStreamTag();
        }
 internal MessageParser(Func <IMessage> factory, bool discardUnknownFields, ExtensionRegistry extensions)
 {
     this.factory         = factory;
     DiscardUnknownFields = discardUnknownFields;
     Extensions           = extensions;
 }
 /// <summary>
 /// Creates a new message parser which registers extensions from the specified registry upon creating the message instance
 /// </summary>
 /// <param name="registry">The extensions to register</param>
 /// <returns>A newly configured message parser.</returns>
 public MessageParser WithExtensionRegistry(ExtensionRegistry registry) =>
 new MessageParser(factory, DiscardUnknownFields, registry);
 internal static void MergeFrom(this IMessage message, ReadOnlySequence <byte> data, bool discardUnknownFields, ExtensionRegistry registry)
 {
     ParseContext.Initialize(data, out ParseContext ctx);
     ctx.DiscardUnknownFields = discardUnknownFields;
     ctx.ExtensionRegistry    = registry;
     ParsingPrimitivesMessages.ReadRawMessage(ref ctx, message);
     ParsingPrimitivesMessages.CheckReadEndOfStreamTag(ref ctx.state);
 }
        // Implementations allowing unknown fields to be discarded.
        internal static void MergeFrom(this IMessage message, byte[] data, bool discardUnknownFields, ExtensionRegistry registry)
        {
            ProtoPreconditions.CheckNotNull(message, nameof(message));
            ProtoPreconditions.CheckNotNull(data, nameof(data));
            CodedInputStream input = new CodedInputStream(data)
            {
                DiscardUnknownFields = discardUnknownFields,
                ExtensionRegistry    = registry
            };

            message.MergeFrom(input);
            input.CheckReadEndOfStreamTag();
        }