aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/MessageParser.cs
diff options
context:
space:
mode:
authorJan Tattermusch <jtattermusch@google.com>2017-11-09 14:23:14 +0100
committerJan Tattermusch <jtattermusch@google.com>2017-11-10 09:00:52 +0100
commit435f61102bf23b9c9be2592d27b8935a8717e610 (patch)
treeabef16d8e433a61b525dde7f5693afff312adcbc /csharp/src/Google.Protobuf/MessageParser.cs
parent5eb717c3006ad7da9aa6e49d40328a3963ad22a3 (diff)
downloadprotobuf-435f61102bf23b9c9be2592d27b8935a8717e610.tar.gz
protobuf-435f61102bf23b9c9be2592d27b8935a8717e610.tar.bz2
protobuf-435f61102bf23b9c9be2592d27b8935a8717e610.zip
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>