aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/MessageExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/MessageExtensions.cs')
-rw-r--r--csharp/src/Google.Protobuf/MessageExtensions.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/MessageExtensions.cs b/csharp/src/Google.Protobuf/MessageExtensions.cs
index 047156c3..9dbc49d6 100644
--- a/csharp/src/Google.Protobuf/MessageExtensions.cs
+++ b/csharp/src/Google.Protobuf/MessageExtensions.cs
@@ -54,6 +54,22 @@ namespace Google.Protobuf
}
/// <summary>
+ /// Merges data from the given byte array slice into an existing message.
+ /// </summary>
+ /// <param name="message">The message to merge the data into.</param>
+ /// <param name="data">The data containing the slice to merge, which must be protobuf-encoded binary data.</param>
+ /// <param name="offset">The offset of the slice to merge.</param>
+ /// <param name="length">The length of the slice to merge.</param>
+ public static void MergeFrom(this IMessage message, byte[] data, int offset, int length)
+ {
+ ProtoPreconditions.CheckNotNull(message, "message");
+ ProtoPreconditions.CheckNotNull(data, "data");
+ CodedInputStream input = new CodedInputStream(data, offset, length);
+ message.MergeFrom(input);
+ input.CheckReadEndOfStreamTag();
+ }
+
+ /// <summary>
/// Merges data from the given byte string into an existing message.
/// </summary>
/// <param name="message">The message to merge the data into.</param>