Table of Contents

Class RawBsonArray

Namespace
MongoDB.Bson
Assembly
MongoDB.Bson.dll

Represents an immutable BSON array that is represented using only the raw bytes.

[BsonSerializer(typeof(RawBsonArraySerializer))]
public class RawBsonArray : BsonArray, IComparable<BsonValue>, IConvertible, IEquatable<BsonValue>, IComparable<BsonArray>, IEquatable<BsonArray>, IList<BsonValue>, ICollection<BsonValue>, IEnumerable<BsonValue>, IEnumerable, IDisposable
Inheritance
RawBsonArray
Implements
Inherited Members
Extension Methods

Constructors

RawBsonArray(IByteBuffer)

Initializes a new instance of the RawBsonArray class.

public RawBsonArray(IByteBuffer slice)

Parameters

slice IByteBuffer

The slice.

Exceptions

ArgumentNullException

slice

ArgumentException

RawBsonArray cannot be used with an IByteBuffer that needs disposing.

Properties

Capacity

Gets or sets the total number of elements the internal data structure can hold without resizing.

public override int Capacity { get; set; }

Property Value

int

Count

Gets the count of array elements.

public override int Count { get; }

Property Value

int

IsReadOnly

Gets whether the array is read-only.

public override bool IsReadOnly { get; }

Property Value

bool

this[int]

Gets or sets a value by position.

public override BsonValue this[int index] { get; set; }

Parameters

index int

The position.

Property Value

BsonValue

The value.

RawValues

Gets the array elements as raw values (see BsonValue.RawValue).

[Obsolete("Use ToArray to ToList instead.")]
public override IEnumerable<object> RawValues { get; }

Property Value

IEnumerable<object>

Slice

Gets the slice.

public IByteBuffer Slice { get; }

Property Value

IByteBuffer

The slice.

Values

Gets the array elements.

public override IEnumerable<BsonValue> Values { get; }

Property Value

IEnumerable<BsonValue>

Methods

Add(BsonValue)

Adds an element to the array.

public override BsonArray Add(BsonValue value)

Parameters

value BsonValue

The value to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<BsonValue>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<BsonValue> values)

Parameters

values IEnumerable<BsonValue>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<ObjectId>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<ObjectId> values)

Parameters

values IEnumerable<ObjectId>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<bool>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<bool> values)

Parameters

values IEnumerable<bool>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<DateTime>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<DateTime> values)

Parameters

values IEnumerable<DateTime>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<double>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<double> values)

Parameters

values IEnumerable<double>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<int>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<int> values)

Parameters

values IEnumerable<int>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<long>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<long> values)

Parameters

values IEnumerable<long>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable<string>)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable<string> values)

Parameters

values IEnumerable<string>

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

AddRange(IEnumerable)

Adds multiple elements to the array.

public override BsonArray AddRange(IEnumerable values)

Parameters

values IEnumerable

A list of values to add to the array.

Returns

BsonArray

The array (so method calls can be chained).

Clear()

Clears the array.

public override void Clear()

Clone()

Creates a shallow clone of the array (see also DeepClone).

public override BsonValue Clone()

Returns

BsonValue

A shallow clone of the array.

Contains(BsonValue)

Tests whether the array contains a value.

public override bool Contains(BsonValue value)

Parameters

value BsonValue

The value to test for.

Returns

bool

True if the array contains the value.

CopyTo(BsonValue[], int)

Copies elements from this array to another array.

public override void CopyTo(BsonValue[] array, int arrayIndex)

Parameters

array BsonValue[]

The other array.

arrayIndex int

The zero based index of the other array at which to start copying.

CopyTo(object[], int)

Copies elements from this array to another array as raw values (see BsonValue.RawValue).

[Obsolete("Use ToArray or ToList instead.")]
public override void CopyTo(object[] array, int arrayIndex)

Parameters

array object[]

The other array.

arrayIndex int

The zero based index of the other array at which to start copying.

DeepClone()

Creates a deep clone of the array (see also Clone).

public override BsonValue DeepClone()

Returns

BsonValue

A deep clone of the array.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetEnumerator()

Gets an enumerator that can enumerate the elements of the array.

public override IEnumerator<BsonValue> GetEnumerator()

Returns

IEnumerator<BsonValue>

An enumerator.

IndexOf(BsonValue)

Gets the index of a value in the array.

public override int IndexOf(BsonValue value)

Parameters

value BsonValue

The value to search for.

Returns

int

The zero based index of the value (or -1 if not found).

IndexOf(BsonValue, int)

Gets the index of a value in the array.

public override int IndexOf(BsonValue value, int index)

Parameters

value BsonValue

The value to search for.

index int

The zero based index at which to start the search.

Returns

int

The zero based index of the value (or -1 if not found).

IndexOf(BsonValue, int, int)

Gets the index of a value in the array.

public override int IndexOf(BsonValue value, int index, int count)

Parameters

value BsonValue

The value to search for.

index int

The zero based index at which to start the search.

count int

The number of elements to search.

Returns

int

The zero based index of the value (or -1 if not found).

Insert(int, BsonValue)

Inserts a new value into the array.

public override void Insert(int index, BsonValue value)

Parameters

index int

The zero based index at which to insert the new value.

value BsonValue

The new value.

Materialize(BsonBinaryReaderSettings)

Materializes the RawBsonArray into a regular BsonArray.

public BsonArray Materialize(BsonBinaryReaderSettings binaryReaderSettings)

Parameters

binaryReaderSettings BsonBinaryReaderSettings

The binary reader settings.

Returns

BsonArray

A BsonArray.

Remove(BsonValue)

Removes the first occurrence of a value from the array.

public override bool Remove(BsonValue value)

Parameters

value BsonValue

The value to remove.

Returns

bool

True if the value was removed.

RemoveAt(int)

Removes an element from the array.

public override void RemoveAt(int index)

Parameters

index int

The zero based index of the element to remove.

ThrowIfDisposed()

Throws if disposed.

protected void ThrowIfDisposed()

Exceptions

ObjectDisposedException

ToArray()

Converts the BsonArray to an array of BsonValues.

public override BsonValue[] ToArray()

Returns

BsonValue[]

An array of BsonValues.

ToList()

Converts the BsonArray to a list of BsonValues.

public override List<BsonValue> ToList()

Returns

List<BsonValue>

A list of BsonValues.

ToString()

Returns a string representation of the array.

public override string ToString()

Returns

string

A string representation of the array.