Google.Protobuf.MessageExtensions

Extension methods on IMessage and IMessage{T}.

Summary

Public static functions

MergeDelimitedFrom(this IMessage message, Stream input)
void
Merges length-delimited data from the given stream into an existing message.
MergeFrom(this IMessage message, byte[] data)
void
Merges data from the given byte array into an existing message.
MergeFrom(this IMessage message, ByteString data)
void
Merges data from the given byte string into an existing message.
MergeFrom(this IMessage message, Stream input)
void
Merges data from the given stream into an existing message.
ToByteArray(this IMessage message)
byte[]
Converts the given message into a byte array in protobuf encoding.
ToByteString(this IMessage message)
ByteString
Converts the given message into a byte string in protobuf encoding.
WriteDelimitedTo(this IMessage message, Stream output)
void
Writes the length and then data of the given message to a stream.
WriteTo(this IMessage message, Stream output)
void
Writes the given message data to the given stream in protobuf encoding.

Public static functions

MergeDelimitedFrom

void MergeDelimitedFrom(
  this IMessage message,
  Stream input
)

Merges length-delimited data from the given stream into an existing 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.

Details
Parameters
message
The message to merge the data into.
input
Stream containing the data to merge, which must be protobuf-encoded binary data.

MergeFrom

void MergeFrom(
  this IMessage message,
  byte[] data
)

Merges data from the given byte array into an existing message.

Details
Parameters
message
The message to merge the data into.
data
The data to merge, which must be protobuf-encoded binary data.

MergeFrom

void MergeFrom(
  this IMessage message,
  ByteString data
)

Merges data from the given byte string into an existing message.

Details
Parameters
message
The message to merge the data into.
data
The data to merge, which must be protobuf-encoded binary data.

MergeFrom

void MergeFrom(
  this IMessage message,
  Stream input
)

Merges data from the given stream into an existing message.

Details
Parameters
message
The message to merge the data into.
input
Stream containing the data to merge, which must be protobuf-encoded binary data.

ToByteArray

byte[] ToByteArray(
  this IMessage message
)

Converts the given message into a byte array in protobuf encoding.

Details
Parameters
message
The message to convert.
Returns
The message data as a byte array.

ToByteString

ByteString ToByteString(
  this IMessage message
)

Converts the given message into a byte string in protobuf encoding.

Details
Parameters
message
The message to convert.
Returns
The message data as a byte string.

WriteDelimitedTo

void WriteDelimitedTo(
  this IMessage message,
  Stream output
)

Writes the length and then data of the given message to a stream.

Details
Parameters
message
The message to write.
output
The output stream to write to.

WriteTo

void WriteTo(
  this IMessage message,
  Stream output
)

Writes the given message data to the given stream in protobuf encoding.

Details
Parameters
message
The message to write to the stream.
output
The stream to write to.