Class MaterializedOnDemandBsonArray
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
Count
Gets the count of array elements.
public override int Count { get; }
Property Value
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
intThe 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
Values
Gets the array elements.
public override IEnumerable<BsonValue> Values { get; }
Property Value
Methods
Add(BsonValue)
Adds an element to the array.
public override BsonArray Add(BsonValue value)
Parameters
value
BsonValueThe 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
IEnumerableA 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
BsonArrayThe 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
BsonValueThe 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
BsonValueThe 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
intThe 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
intThe 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
booltrue
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
Returns
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
BsonValueThe 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
BsonValueThe value to search for.
index
intThe 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
BsonValueThe value to search for.
index
intThe zero based index at which to start the search.
count
intThe 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
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
BsonValueThe 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
intThe zero based index of the element to remove.
ThrowIfDisposed()
Throws if disposed.
protected void ThrowIfDisposed()
Exceptions
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
ToString()
Returns a string representation of the array.
public override string ToString()
Returns
- string
A string representation of the array.