public class MessageParser : object
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.
Type | Name | Description |
---|---|---|
Stream | input | The stream to parse. |
Type | Description |
---|---|
IMessage | The parsed message. |
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.
Type | Name | Description |
---|---|---|
ByteString | data | The data to parse. |
Type | Description |
---|---|
IMessage | The parsed message. |
ParseFrom(CodedInputStream)
public IMessage ParseFrom(CodedInputStream input)
Parses a message from the given coded input stream.
Type | Name | Description |
---|---|---|
CodedInputStream | input | The stream to parse. |
Type | Description |
---|---|
IMessage | The parsed message. |
ParseFrom(ReadOnlySequence<Byte>)
public IMessage ParseFrom(ReadOnlySequence<byte> data)
Parses a message from the given sequence.
Type | Name | Description |
---|---|---|
ReadOnlySequence<Byte> | data | The data to parse. |
Type | Description |
---|---|
IMessage | The parsed message. |
ParseFrom(Stream)
public IMessage ParseFrom(Stream input)
Parses a message from the given stream.
Type | Name | Description |
---|---|---|
Stream | input | The stream to parse. |
Type | Description |
---|---|
IMessage | The parsed message. |
ParseFrom(Byte[])
public IMessage ParseFrom(byte[] data)
Parses a message from a byte array.
Type | Name | Description |
---|---|---|
Byte[] | data | The byte array containing the message. Must not be null. |
Type | Description |
---|---|
IMessage | The newly parsed message. |
ParseFrom(Byte[], Int32, Int32)
public IMessage ParseFrom(byte[] data, int offset, int length)
Parses a message from a byte array slice.
Type | Name | Description |
---|---|---|
Byte[] | data | The byte array containing the message. Must not be null. |
Int32 | offset | The offset of the slice to parse. |
Int32 | length | The length of the slice to parse. |
Type | Description |
---|---|
IMessage | The newly parsed message. |
ParseJson(String)
public IMessage ParseJson(string json)
Parses a message from the given JSON.
Type | Name | Description |
---|---|---|
String | json | The JSON to parse. |
Type | Description |
---|---|
IMessage | The parsed message. |
Type | Condition |
---|---|
InvalidJsonException | The JSON does not comply with RFC 7159 |
InvalidProtocolBufferException | The JSON does not represent a Protocol Buffers message correctly |
WithDiscardUnknownFields(Boolean)
public MessageParser WithDiscardUnknownFields(bool discardUnknownFields)
Creates a new message parser which optionally discards unknown fields when parsing.
Type | Name | Description |
---|---|---|
Boolean | discardUnknownFields | Whether or not to discard unknown fields when parsing. |
Type | Description |
---|---|
MessageParser | A newly configured message parser. |
WithExtensionRegistry(ExtensionRegistry)
public MessageParser WithExtensionRegistry(ExtensionRegistry registry)
Creates a new message parser which registers extensions from the specified registry upon creating the message instance
Type | Name | Description |
---|---|---|
ExtensionRegistry | registry | The extensions to register |
Type | Description |
---|---|
MessageParser | A newly configured message parser. |