Class BsonStreamAdapter
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
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
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
ReadTimeout
public override int ReadTimeout { get; set; }
Property Value
WriteTimeout
public override int WriteTimeout { get; set; }
Property Value
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
intcount
intcallback
AsyncCallbackstate
object
Returns
BeginWrite(byte[], int, int, AsyncCallback, object)
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
Parameters
buffer
byte[]offset
intcount
intcallback
AsyncCallbackstate
object
Returns
Close()
public override void Close()
CopyToAsync(Stream, int, CancellationToken)
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
Parameters
destination
StreambufferSize
intcancellationToken
CancellationToken
Returns
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposing
bool
EndRead(IAsyncResult)
public override int EndRead(IAsyncResult asyncResult)
Parameters
asyncResult
IAsyncResult
Returns
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
Read(byte[], int, int)
public override int Read(byte[] buffer, int offset, int count)
Parameters
Returns
ReadAsync(byte[], int, int, CancellationToken)
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
buffer
byte[]offset
intcount
intcancellationToken
CancellationToken
Returns
ReadByte()
public override int ReadByte()
Returns
ReadCString(UTF8Encoding)
Reads a BSON CString from the stream.
public override string ReadCString(UTF8Encoding encoding)
Parameters
encoding
UTF8EncodingThe 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
encoding
UTF8EncodingThe encoding.
Returns
- string
A string.
Seek(long, SeekOrigin)
public override long Seek(long offset, SeekOrigin origin)
Parameters
offset
longorigin
SeekOrigin
Returns
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
WriteAsync(byte[], int, int, CancellationToken)
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
buffer
byte[]offset
intcount
intcancellationToken
CancellationToken
Returns
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
stringThe 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
Decimal128The value.
WriteDouble(double)
Writes a BSON double to the stream.
public override void WriteDouble(double value)
Parameters
value
doubleThe value.
WriteInt32(int)
Writes a 32-bit BSON integer to the stream.
public override void WriteInt32(int value)
Parameters
value
intThe value.
WriteInt64(long)
Writes a 64-bit BSON integer to the stream.
public override void WriteInt64(long value)
Parameters
value
longThe value.
WriteObjectId(ObjectId)
Writes a BSON ObjectId to the stream.
public override void WriteObjectId(ObjectId value)
Parameters
value
ObjectIdThe value.
WriteString(string, UTF8Encoding)
Writes a BSON string to the stream.
public override void WriteString(string value, UTF8Encoding encoding)
Parameters
value
stringThe value.
encoding
UTF8EncodingThe encoding.