Class ByteBufferStream
Represents a Stream backed by an IByteBuffer. Similar to MemoryStream but backed by an IByteBuffer instead of a byte array and also implements the BsonStream interface for higher performance BSON I/O.
public class ByteBufferStream : BsonStream, IDisposable, IStreamEfficientCopyTo
- Inheritance
-
ByteBufferStream
- Implements
- Inherited Members
- Extension Methods
Constructors
ByteBufferStream(IByteBuffer, bool)
Initializes a new instance of the ByteBufferStream class.
public ByteBufferStream(IByteBuffer buffer, bool ownsBuffer = false)
Parameters
bufferIByteBufferThe buffer.
ownsBufferboolWhether the stream owns the buffer and should Dispose it when done.
Properties
Buffer
Gets the buffer.
public IByteBuffer Buffer { get; }
Property Value
- IByteBuffer
The buffer.
CanRead
public override bool CanRead { get; }
Property Value
CanSeek
public override bool CanSeek { get; }
Property Value
CanTimeout
public override bool CanTimeout { get; }
Property Value
CanWrite
public override bool CanWrite { get; }
Property Value
Length
public override long Length { get; }
Property Value
Position
public override long Position { get; set; }
Property Value
Methods
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposingbool
EfficientCopyTo(Stream)
Copy the current stream to the destination without making unnecessary copies of the bytes.
public void EfficientCopyTo(Stream destination)
Parameters
destinationStreamThe destination stream.
Flush()
public override void Flush()
Read(byte[], int, int)
public override int Read(byte[] buffer, int offset, int count)
Parameters
Returns
ReadByte()
public override int ReadByte()
Returns
ReadCString(UTF8Encoding)
Reads a BSON CString from the stream.
public override string ReadCString(UTF8Encoding encoding)
Parameters
encodingUTF8EncodingThe encoding.
Returns
- string
A string.
ReadCStringBytes()
Reads a BSON CString from the stream.
public override ArraySegment<byte> ReadCStringBytes()
Returns
- ArraySegment<byte>
An ArraySegment containing the CString bytes (without the null byte).
ReadDecimal128()
Reads a BSON Decimal128 from the stream.
public override Decimal128 ReadDecimal128()
Returns
ReadDouble()
Reads a BSON double from the stream.
public override double ReadDouble()
Returns
- double
A double.
ReadInt32()
Reads a 32-bit BSON integer from the stream.
public override int ReadInt32()
Returns
- int
An int.
ReadInt64()
Reads a 64-bit BSON integer from the stream.
public override long ReadInt64()
Returns
- long
A long.
ReadObjectId()
Reads a BSON ObjectId from the stream.
public override ObjectId ReadObjectId()
Returns
- ObjectId
An ObjectId.
ReadSlice()
Reads a raw length prefixed slice from the stream.
public override IByteBuffer ReadSlice()
Returns
- IByteBuffer
A slice.
ReadString(UTF8Encoding)
Reads a BSON string from the stream.
public override string ReadString(UTF8Encoding encoding)
Parameters
encodingUTF8EncodingThe encoding.
Returns
- string
A string.
Seek(long, SeekOrigin)
public override long Seek(long offset, SeekOrigin origin)
Parameters
offsetlongoriginSeekOrigin
Returns
SetLength(long)
public override void SetLength(long value)
Parameters
valuelong
SkipCString()
Skips over a BSON CString leaving the stream positioned just after the terminating null byte.
public override void SkipCString()
Write(byte[], int, int)
public override void Write(byte[] buffer, int offset, int count)
Parameters
WriteByte(byte)
public override void WriteByte(byte value)
Parameters
valuebyte
WriteCString(string)
Writes a BSON CString to the stream.
public override void WriteCString(string value)
Parameters
valuestringThe value.
WriteCStringBytes(byte[])
Writes the CString bytes to the stream.
public override void WriteCStringBytes(byte[] value)
Parameters
valuebyte[]The value.
WriteDecimal128(Decimal128)
Writes a BSON Decimal128 to the stream.
public override void WriteDecimal128(Decimal128 value)
Parameters
valueDecimal128The value.
WriteDouble(double)
Writes a BSON double to the stream.
public override void WriteDouble(double value)
Parameters
valuedoubleThe value.
WriteInt32(int)
Writes a 32-bit BSON integer to the stream.
public override void WriteInt32(int value)
Parameters
valueintThe value.
WriteInt64(long)
Writes a 64-bit BSON integer to the stream.
public override void WriteInt64(long value)
Parameters
valuelongThe value.
WriteObjectId(ObjectId)
Writes a BSON ObjectId to the stream.
public override void WriteObjectId(ObjectId value)
Parameters
valueObjectIdThe value.
WriteString(string, UTF8Encoding)
Writes a BSON string to the stream.
public override void WriteString(string value, UTF8Encoding encoding)
Parameters
valuestringThe value.
encodingUTF8EncodingThe encoding.