Show / Hide Table of Contents

Class MessageParser

A general message parser, typically used by reflection-based code as all the methods return simple IMessage.

Inheritance
System.Object
MessageParser
MessageParser<T>
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Protobuf
Assembly: Google.Protobuf.dll
Syntax
public class MessageParser

Methods

ParseDelimitedFrom(Stream)

Parses a length-delimited message from the given stream.

Declaration
public IMessage ParseDelimitedFrom(Stream input)
Parameters
Type Name Description
System.IO.Stream input

The stream to parse.

Returns
Type Description
IMessage

The parsed message.

Remarks

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)

Parses a message from the given byte string.

Declaration
public IMessage ParseFrom(ByteString data)
Parameters
Type Name Description
ByteString data

The data to parse.

Returns
Type Description
IMessage

The parsed message.

ParseFrom(CodedInputStream)

Parses a message from the given coded input stream.

Declaration
public IMessage ParseFrom(CodedInputStream input)
Parameters
Type Name Description
CodedInputStream input

The stream to parse.

Returns
Type Description
IMessage

The parsed message.

ParseFrom(Byte[])

Parses a message from a byte array.

Declaration
public IMessage ParseFrom(byte[] data)
Parameters
Type Name Description
System.Byte[] data

The byte array containing the message. Must not be null.

Returns
Type Description
IMessage

The newly parsed message.

ParseFrom(Byte[], Int32, Int32)

Parses a message from a byte array slice.

Declaration
public IMessage ParseFrom(byte[] data, int offset, int length)
Parameters
Type Name Description
System.Byte[] data

The byte array containing the message. Must not be null.

System.Int32 offset

The offset of the slice to parse.

System.Int32 length

The length of the slice to parse.

Returns
Type Description
IMessage

The newly parsed message.

ParseFrom(Stream)

Parses a message from the given stream.

Declaration
public IMessage ParseFrom(Stream input)
Parameters
Type Name Description
System.IO.Stream input

The stream to parse.

Returns
Type Description
IMessage

The parsed message.

ParseJson(String)

Parses a message from the given JSON.

Declaration
public IMessage ParseJson(string json)
Parameters
Type Name Description
System.String json

The JSON to parse.

Returns
Type Description
IMessage

The parsed message.

Exceptions
Type Condition
InvalidJsonException

The JSON does not comply with RFC 7159

InvalidProtocolBufferException

The JSON does not represent a Protocol Buffers message correctly

WithDiscardUnknownFields(Boolean)

Creates a new message parser which optionally discards unknown fields when parsing.

Declaration
public MessageParser WithDiscardUnknownFields(bool discardUnknownFields)
Parameters
Type Name Description
System.Boolean discardUnknownFields

Whether or not to discard unknown fields when parsing.

Returns
Type Description
MessageParser

A newly configured message parser.

Back to top