Table of Contents

Class BsonStreamAdapter

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

A Stream that wraps another Stream while implementing the BsonStream abstract methods.

public sealed class BsonStreamAdapter : BsonStream, IDisposable
Inheritance
BsonStreamAdapter
Implements
Inherited Members
Extension Methods

Constructors

BsonStreamAdapter(Stream, bool)

Initializes a new instance of the BsonStreamAdapter class.

public BsonStreamAdapter(Stream stream, bool ownsStream = false)

Parameters

stream Stream

The stream.

ownsStream bool

if set to true [owns stream].

Exceptions

ArgumentNullException

stream

Properties

BaseStream

Gets the base stream.

public Stream BaseStream { get; }

Property Value

Stream

The base stream.

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

ReadTimeout

public override int ReadTimeout { get; set; }

Property Value

int

WriteTimeout

public override int WriteTimeout { get; set; }

Property Value

int

Methods

BeginRead(byte[], int, int, AsyncCallback, object)

public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)

Parameters

buffer byte[]
offset int
count int
callback AsyncCallback
state object

Returns

IAsyncResult

BeginWrite(byte[], int, int, AsyncCallback, object)

public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)

Parameters

buffer byte[]
offset int
count int
callback AsyncCallback
state object

Returns

IAsyncResult

Close()

public override void Close()

CopyToAsync(Stream, int, CancellationToken)

public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)

Parameters

destination Stream
bufferSize int
cancellationToken CancellationToken

Returns

Task

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

EndRead(IAsyncResult)

public override int EndRead(IAsyncResult asyncResult)

Parameters

asyncResult IAsyncResult

Returns

int

EndWrite(IAsyncResult)

public override void EndWrite(IAsyncResult asyncResult)

Parameters

asyncResult IAsyncResult

Flush()

public override void Flush()

FlushAsync(CancellationToken)

public override Task FlushAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

Read(byte[], int, int)

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

Parameters

buffer byte[]
offset int
count int

Returns

int

ReadAsync(byte[], int, int, CancellationToken)

public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)

Parameters

buffer byte[]
offset int
count int
cancellationToken CancellationToken

Returns

Task<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

WriteAsync(byte[], int, int, CancellationToken)

public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)

Parameters

buffer byte[]
offset int
count int
cancellationToken CancellationToken

Returns

Task

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.