aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/MessageParser.cs
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2017-11-09 14:23:14 +0100
committerGravatar Jan Tattermusch <jtattermusch@google.com>2017-11-09 14:23:14 +0100
commit0c874a6a1901d5c4ebb9d09f218eb9e348b7279c (patch)
tree7c3983d6a13d9a7de6d209ce3a71edafeb120b31 /csharp/src/Google.Protobuf/MessageParser.cs
parentc258fb303a804241cb2678dc732ed870a0ee97c8 (diff)
allow message parsing from an array slice
Diffstat (limited to 'csharp/src/Google.Protobuf/MessageParser.cs')
-rw-r--r--csharp/src/Google.Protobuf/MessageParser.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/MessageParser.cs b/csharp/src/Google.Protobuf/MessageParser.cs
index 8889638b..569414b0 100644
--- a/csharp/src/Google.Protobuf/MessageParser.cs
+++ b/csharp/src/Google.Protobuf/MessageParser.cs
@@ -71,6 +71,21 @@ namespace Google.Protobuf
}
/// <summary>
+ /// Parses a message from a byte array slice.
+ /// </summary>
+ /// <param name="data">The byte array containing the message. Must not be null.</param>
+ /// <param name="offset">The offset of the slice to parse.</param>
+ /// <param name="length">The length of the slice to parse.</param>
+ /// <returns>The newly parsed message.</returns>
+ public IMessage ParseFrom(byte[] data, int offset, int length)
+ {
+ ProtoPreconditions.CheckNotNull(data, "data");
+ IMessage message = factory();
+ message.MergeFrom(data, offset, length);
+ return message;
+ }
+
+ /// <summary>
/// Parses a message from the given byte string.
/// </summary>
/// <param name="data">The data to parse.</param>