public class MessageParser
A general message parser, typically used by reflection-based code as all the methods return simple IMessage .
Derived Types
Namespace
Google.ProtobufAssembly
Google.Protobuf.dll
Methods
ParseDelimitedFrom(Stream)
public IMessage ParseDelimitedFrom(Stream input)
Parses a length-delimited message from the given stream.
The stream is expected to contain a length and then the data. Only the amount of data specified by the length will be consumed.
ParseFrom(ByteString)
public IMessage ParseFrom(ByteString data)
Parses a message from the given byte string.
ParseFrom(CodedInputStream)
public IMessage ParseFrom(CodedInputStream input)
Parses a message from the given coded input stream.
ParseFrom(ReadOnlySequence<byte>)
public IMessage ParseFrom(ReadOnlySequence<byte> data)
Parses a message from the given sequence.
ParseFrom(byte[])
public IMessage ParseFrom(byte[] data)
Parses a message from a byte array.
ParseFrom(byte[], int, int)
public IMessage ParseFrom(byte[] data, int offset, int length)
Parses a message from a byte array slice.
ParseFrom(Stream)
public IMessage ParseFrom(Stream input)
Parses a message from the given stream.
ParseFrom(ReadOnlySpan<byte>)
public IMessage ParseFrom(ReadOnlySpan<byte> data)
Parses a message from the given span.
ParseJson(string)
public IMessage ParseJson(string json)
Parses a message from the given JSON.
This method always uses the default JSON parser; it is not affected by WithDiscardUnknownFields(bool) . To ignore unknown fields when parsing JSON, create a JsonParser using a JsonParser.Settings with IgnoreUnknownFields set to true and call Parse<T>(string) directly.
The JSON does not comply with RFC 7159
The JSON does not represent a Protocol Buffers message correctly
WithDiscardUnknownFields(bool)
public MessageParser WithDiscardUnknownFields(bool discardUnknownFields)
Creates a new message parser which optionally discards unknown fields when parsing.
discardUnknownFields
Note that this does not affect the behavior of ParseJson(string) at all. To ignore unknown fields when parsing JSON, create a JsonParser using a JsonParser.Settings with IgnoreUnknownFields set to true and call Parse<T>(string) directly.
WithExtensionRegistry(ExtensionRegistry)
public
MessageParser
WithExtensionRegistry
(
ExtensionRegistry
registry
)
Creates a new message parser which registers extensions from the specified registry upon creating the message instance