Table of Contents

Class ByteBufferStream

Namespace
MongoDB.Bson.IO
Assembly
MongoDB.Bson.dll

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

buffer IByteBuffer

The buffer.

ownsBuffer bool

Whether 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

bool

CanSeek

public override bool CanSeek { get; }

Property Value

bool

CanTimeout

public override bool CanTimeout { get; }

Property Value

bool

CanWrite

public override bool CanWrite { get; }

Property Value

bool

Length

public override long Length { get; }

Property Value

long

Position

public override long Position { get; set; }

Property Value

long

Methods

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

EfficientCopyTo(Stream)

Copy the current stream to the destination without making unnecessary copies of the bytes.

public void EfficientCopyTo(Stream destination)

Parameters

destination Stream

The destination stream.

Flush()

public override void Flush()

Read(byte[], int, int)

public override int Read(byte[] buffer, int offset, int count)

Parameters

buffer byte[]
offset int
count int

Returns

int

ReadByte()

public override int ReadByte()

Returns

int

ReadCString(UTF8Encoding)

Reads a BSON CString from the stream.

public override string ReadCString(UTF8Encoding encoding)

Parameters

encoding UTF8Encoding

The 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

Decimal128

A Decimal128.

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

encoding UTF8Encoding

The encoding.

Returns

string

A string.

Seek(long, SeekOrigin)

public override long Seek(long offset, SeekOrigin origin)

Parameters

offset long
origin SeekOrigin

Returns

long

SetLength(long)

public override void SetLength(long value)

Parameters

value long

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

buffer byte[]
offset int
count int

WriteByte(byte)

public override void WriteByte(byte value)

Parameters

value byte

WriteCString(string)

Writes a BSON CString to the stream.

public override void WriteCString(string value)

Parameters

value string

The value.

WriteCStringBytes(byte[])

Writes the CString bytes to the stream.

public override void WriteCStringBytes(byte[] value)

Parameters

value byte[]

The value.

WriteDecimal128(Decimal128)

Writes a BSON Decimal128 to the stream.

public override void WriteDecimal128(Decimal128 value)

Parameters

value Decimal128

The value.

WriteDouble(double)

Writes a BSON double to the stream.

public override void WriteDouble(double value)

Parameters

value double

The value.

WriteInt32(int)

Writes a 32-bit BSON integer to the stream.

public override void WriteInt32(int value)

Parameters

value int

The value.

WriteInt64(long)

Writes a 64-bit BSON integer to the stream.

public override void WriteInt64(long value)

Parameters

value long

The value.

WriteObjectId(ObjectId)

Writes a BSON ObjectId to the stream.

public override void WriteObjectId(ObjectId value)

Parameters

value ObjectId

The value.

WriteString(string, UTF8Encoding)

Writes a BSON string to the stream.

public override void WriteString(string value, UTF8Encoding encoding)

Parameters

value string

The value.

encoding UTF8Encoding

The encoding.