Class MultiChunkBuffer
An IByteBuffer that is backed by multiple chunks.
public sealed class MultiChunkBuffer : IByteBuffer, IDisposable
- Inheritance
-
MultiChunkBuffer
- Implements
- Inherited Members
- Extension Methods
Constructors
MultiChunkBuffer(IBsonChunkSource)
Initializes a new instance of the MultiChunkBuffer class.
public MultiChunkBuffer(IBsonChunkSource chunkSource)
Parameters
chunkSourceIBsonChunkSourceThe chunk pool.
Exceptions
- ArgumentNullException
chunkPool
MultiChunkBuffer(IEnumerable<IBsonChunk>, int?, bool)
Initializes a new instance of the MultiChunkBuffer class.
public MultiChunkBuffer(IEnumerable<IBsonChunk> chunks, int? length = null, bool isReadOnly = false)
Parameters
chunksIEnumerable<IBsonChunk>The chunks.
lengthint?The length.
isReadOnlyboolWhether the buffer is read only.
Exceptions
- ArgumentNullException
chunks
Properties
Capacity
Gets the capacity.
public int Capacity { get; }
Property Value
- int
The capacity.
ChunkSource
Gets the chunk source.
public IBsonChunkSource ChunkSource { get; }
Property Value
- IBsonChunkSource
The chunk source.
IsReadOnly
Gets a value indicating whether this instance is read only.
public bool IsReadOnly { get; }
Property Value
- bool
trueif this instance is read only; otherwise,false.
Length
Gets or sets the length.
public int Length { get; set; }
Property Value
- int
The length.
Methods
AccessBackingBytes(int)
Access the backing bytes directly. The returned ArraySegment will point to the desired position and contain as many bytes as possible up to the next chunk boundary (if any). If the returned ArraySegment does not contain enough bytes for your needs you will have to call ReadBytes instead.
public ArraySegment<byte> AccessBackingBytes(int position)
Parameters
positionintThe position.
Returns
- ArraySegment<byte>
An ArraySegment pointing directly to the backing bytes for the position.
Clear(int, int)
Clears the specified bytes.
public void Clear(int position, int count)
Parameters
Dispose()
public void Dispose()
EnsureCapacity(int)
Ensure that the buffer has a minimum capacity. Depending on the buffer allocation strategy calling this method may result in a higher capacity than the minimum (but never lower).
public void EnsureCapacity(int minimumCapacity)
Parameters
minimumCapacityintThe minimum capacity.
GetByte(int)
Gets a byte.
public byte GetByte(int position)
Parameters
positionintThe position.
Returns
- byte
A byte.
GetBytes(int, byte[], int, int)
Gets bytes.
public void GetBytes(int position, byte[] destination, int offset, int count)
Parameters
positionintThe position.
destinationbyte[]The destination.
offsetintThe destination offset.
countintThe count.
GetSlice(int, int)
Gets a slice of this buffer.
public IByteBuffer GetSlice(int position, int length)
Parameters
Returns
- IByteBuffer
A slice of this buffer.
MakeReadOnly()
Makes this buffer read only.
public void MakeReadOnly()
SetByte(int, byte)
Sets a byte.
public void SetByte(int position, byte value)
Parameters
SetBytes(int, byte[], int, int)
Sets bytes.
public void SetBytes(int position, byte[] source, int offset, int count)