Merge pull request #288 from mfcollins3/csharp-byte-buffer

Add Get Bytes Method Generator for C#
This commit is contained in:
Wouter van Oortmerssen
2015-12-07 17:35:57 -08:00
9 changed files with 70 additions and 12 deletions

View File

@@ -67,6 +67,21 @@ namespace FlatBuffers
return offset + bb.GetInt(offset) + sizeof(int); // data starts after the length
}
// Get the data of a vector whoses offset is stored at "offset" in this object as an
// ArraySegment<byte>. If the vector is not present in the ByteBuffer,
// then a null value will be returned.
protected ArraySegment<byte>? __vector_as_arraysegment(int offset) {
var o = this.__offset(offset);
if (0 == o)
{
return null;
}
var pos = this.__vector(o);
var len = this.__vector_len(o);
return new ArraySegment<byte>(this.bb.Data, pos, len);
}
// Initialize any Table-derived type to point to the union at the given offset.
protected TTable __union<TTable>(TTable t, int offset) where TTable : Table
{