Table of Contents

Class MaterializedOnDemandBsonArray

Namespace
MongoDB.Bson
Assembly
MongoDB.Bson.dll

Represents a BSON array that is not materialized until you start using it.

[BsonSerializer(typeof(MaterializedOnDemandBsonArray.MaterializedOnDemandBsonArraySerializer))]
public abstract class MaterializedOnDemandBsonArray : BsonArray, IComparable<BsonValue>, IConvertible, IEquatable<BsonValue>, IComparable<BsonArray>, IEquatable<BsonArray>, IList<BsonValue>, ICollection<BsonValue>, IEnumerable<BsonValue>, IEnumerable, IDisposable
Inheritance
MaterializedOnDemandBsonArray
Implements
Derived
Inherited Members
Extension Methods

Constructors

MaterializedOnDemandBsonArray()

Initializes a new instance of the MaterializedOnDemandBsonArray class.

protected MaterializedOnDemandBsonArray()

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

IsDisposed

Gets a value indicating whether this instance is disposed.

public bool IsDisposed { get; }

Property Value

bool

true if this instance is disposed; otherwise, false.

IsMaterialized

Gets a value indicating whether this instance is materialized.

public bool IsMaterialized { get; }

Property Value

bool

true if this instance is materialized; otherwise, false.

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>

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.

CompareTo(BsonArray)

Compares the array to another array.

public override int CompareTo(BsonArray other)

Parameters

other BsonArray

The other array.

Returns

int

A 32-bit signed integer that indicates whether this array is less than, equal to, or greather than the other.

CompareTo(BsonValue)

Compares the array to another BsonValue.

public override int CompareTo(BsonValue other)

Parameters

other BsonValue

The other BsonValue.

Returns

int

A 32-bit signed integer that indicates whether this array is less than, equal to, or greather than the other BsonValue.

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.

Equals(object)

Determines whether the specified object, is equal to this instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

GetEnumerator()

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

public override IEnumerator<BsonValue> GetEnumerator()

Returns

IEnumerator<BsonValue>

An enumerator.

GetHashCode()

Gets the hash code.

public override int GetHashCode()

Returns

int

The hash code.

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()

Materializes the BsonArray.

protected abstract IEnumerable<BsonValue> Materialize()

Returns

IEnumerable<BsonValue>

The materialized elements.

MaterializeCompleted()

Informs subclasses that the Materialize process completed so they can free any resources related to the unmaterialized state.

protected abstract void MaterializeCompleted()

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.