Class MaterializedOnDemandBsonDocument
Represents a BSON document that is not materialized until you start using it.
[BsonSerializer(typeof(MaterializedOnDemandBsonDocumentSerializer))]
public abstract class MaterializedOnDemandBsonDocument : BsonDocument, IComparable<BsonValue>, IConvertible, IEquatable<BsonValue>, IComparable<BsonDocument>, IConvertibleToBsonDocument, IEnumerable<BsonElement>, IEnumerable, IEquatable<BsonDocument>, IDisposable
- Inheritance
-
Materialized
OnDemand Bson Document
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
MaterializedOnDemandBsonDocument()
Initializes a new instance of the Materialized
Properties
ElementCount
Gets the number of elements.
Property Value
Elements
Gets the elements.
Property Value
IsDisposed
Gets a value indicating whether this instance is disposed.
Property Value
- bool
true
if this instance is disposed; otherwise,false
.
IsMaterialized
Gets a value indicating whether this instance is materialized.
Property Value
- bool
true
if this instance is materialized; otherwise,false
.
this[int]
Gets or sets a value by position.
Parameters
index
intThe position.
Property Value
- Bson
Value The value.
this[string]
Gets or sets a value by name.
Parameters
name
stringThe name.
Property Value
- Bson
Value The value.
this[string, BsonValue]
Gets the value of an element or a default value if the element is not found.
[Obsolete("Use GetValue(string name, BsonValue defaultValue) instead.")]
public override BsonValue this[string name, BsonValue defaultValue] { get; }
Parameters
name
stringThe name of the element.
defaultValue
BsonValue The default value to return if the element is not found.
Property Value
- Bson
Value Teh value of the element or a default value if the element is not found.
Names
Gets the element names.
Property Value
RawValues
Gets the raw values (see BsonValue.RawValue).
Property Value
Values
Gets the values.
Property Value
Methods
Add(BsonElement)
Adds an element to the document.
Parameters
element
BsonElement The element to add.
Returns
- Bson
Document The document (so method calls can be chained).
Add(params BsonElement[])
Adds a list of elements to the document.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public override BsonDocument Add(params BsonElement[] elements)
Parameters
elements
BsonElement []The list of elements.
Returns
- Bson
Document The document (so method calls can be chained).
Add(Dictionary<string, object>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange instead.")]
public override BsonDocument Add(Dictionary<string, object> dictionary)
Parameters
dictionary
Dictionary<string, object>The dictionary.
Returns
- Bson
Document The document (so method calls can be chained).
Add(Dictionary<string, object>, IEnumerable<string>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public override BsonDocument Add(Dictionary<string, object> dictionary, IEnumerable<string> keys)
Parameters
dictionary
Dictionary<string, object>The dictionary.
keys
IEnumerable<string>Which keys of the hash table to add.
Returns
- Bson
Document The document (so method calls can be chained).
Add(IDictionary<string, object>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange instead.")]
public override BsonDocument Add(IDictionary<string, object> dictionary)
Parameters
dictionary
IDictionary<string, object>The dictionary.
Returns
- Bson
Document The document (so method calls can be chained).
Add(IDictionary<string, object>, IEnumerable<string>)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public override BsonDocument Add(IDictionary<string, object> dictionary, IEnumerable<string> keys)
Parameters
dictionary
IDictionary<string, object>The dictionary.
keys
IEnumerable<string>Which keys of the hash table to add.
Returns
- Bson
Document The document (so method calls can be chained).
Add(IEnumerable<BsonElement>)
Adds a list of elements to the document.
[Obsolete("Use AddRange instead.")]
public override BsonDocument Add(IEnumerable<BsonElement> elements)
Parameters
elements
IEnumerable<BsonElement >The list of elements.
Returns
- Bson
Document The document (so method calls can be chained).
Add(IDictionary)
Adds elements to the document from a dictionary of key/value pairs.
Parameters
dictionary
IDictionaryThe dictionary.
Returns
- Bson
Document The document (so method calls can be chained).
Add(IDictionary, IEnumerable)
Adds elements to the document from a dictionary of key/value pairs.
[Obsolete("Use AddRange(IEnumerable<BsonElement> elements) instead.")]
public override BsonDocument Add(IDictionary dictionary, IEnumerable keys)
Parameters
dictionary
IDictionaryThe dictionary.
keys
IEnumerableWhich keys of the hash table to add.
Returns
- Bson
Document The document (so method calls can be chained).
Add(string, BsonValue)
Creates and adds an element to the document.
Parameters
Returns
- Bson
Document The document (so method calls can be chained).
Add(string, BsonValue, bool)
Creates and adds an element to the document, but only if the condition is true.
Parameters
name
stringThe name of the element.
value
BsonValue The value of the element.
condition
boolWhether to add the element to the document.
Returns
- Bson
Document The document (so method calls can be chained).
Add(string, Func<BsonValue>, bool)
Creates and adds an element to the document, but only if the condition is true. If the condition is false the value factory is not called at all.
Parameters
name
stringThe name of the element.
valueFactory
Func<BsonValue >A delegate called to compute the value of the element if condition is true.
condition
boolWhether to add the element to the document.
Returns
- Bson
Document The document (so method calls can be chained).
AddRange(Dictionary<string, object>)
Adds elements to the document from a dictionary of key/value pairs.
Parameters
dictionary
Dictionary<string, object>The dictionary.
Returns
- Bson
Document The document (so method calls can be chained).
AddRange(IEnumerable<BsonElement>)
Adds a list of elements to the document.
Parameters
elements
IEnumerable<BsonElement >The list of elements.
Returns
- Bson
Document The document (so method calls can be chained).
AddRange(IEnumerable<KeyValuePair<string, object>>)
Adds elements to the document from a dictionary of key/value pairs.
Parameters
dictionary
IEnumerable<KeyValue <string, object>>Pair The dictionary.
Returns
- Bson
Document The document (so method calls can be chained).
AddRange(IDictionary)
Adds elements to the document from a dictionary of key/value pairs.
Parameters
dictionary
IDictionaryThe dictionary.
Returns
- Bson
Document The document (so method calls can be chained).
Clear()
Clears the document (removes all elements).
Clone()
Creates a shallow clone of the document (see also DeepClone).
Returns
- Bson
Value A shallow clone of the document.
CompareTo(BsonDocument)
Compares this document to another document.
Parameters
other
BsonDocument The other document.
Returns
- int
A 32-bit signed integer that indicates whether this document is less than, equal to, or greather than the other.
CompareTo(BsonValue)
Compares the BsonDocument to another BsonValue.
Parameters
other
BsonValue The other BsonValue.
Returns
- int
A 32-bit signed integer that indicates whether this BsonDocument is less than, equal to, or greather than the other BsonValue.
Contains(string)
Tests whether the document contains an element with the specified name.
Parameters
name
stringThe name of the element to look for.
Returns
- bool
True if the document contains an element with the specified name.
ContainsValue(BsonValue)
Tests whether the document contains an element with the specified value.
Parameters
value
BsonValue The value of the element to look for.
Returns
- bool
True if the document contains an element with the specified value.
DeepClone()
Creates a deep clone of the document (see also Clone).
Returns
- Bson
Value A deep clone of the document.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
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.
Parameters
Returns
GetElement(int)
Gets an element of this document.
Parameters
index
intThe zero based index of the element.
Returns
- Bson
Element The element.
GetElement(string)
Gets an element of this document.
Parameters
name
stringThe name of the element.
Returns
- Bson
Element A BsonElement.
GetEnumerator()
Gets an enumerator that can be used to enumerate the elements of this document.
Returns
- IEnumerator<Bson
Element > An enumerator.
GetHashCode()
Returns a hash code for this instance.
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
GetValue(int)
Gets the value of an element.
Parameters
index
intThe zero based index of the element.
Returns
- Bson
Value The value of the element.
GetValue(string)
Gets the value of an element.
Parameters
name
stringThe name of the element.
Returns
- Bson
Value The value of the element.
GetValue(string, BsonValue)
Gets the value of an element or a default value if the element is not found.
Parameters
name
stringThe name of the element.
defaultValue
BsonValue The default value returned if the element is not found.
Returns
- Bson
Value The value of the element or the default value if the element is not found.
InsertAt(int, BsonElement)
Inserts a new element at a specified position.
Parameters
index
intThe position of the new element.
element
BsonElement The element.
Materialize()
Materializes the BsonDocument.
Returns
- IEnumerable<Bson
Element > The materialized elements.
MaterializeCompleted()
Informs subclasses that the Materialize process completed so they can free any resources related to the unmaterialized state.
Merge(BsonDocument)
Merges another document into this one. Existing elements are not overwritten.
Parameters
document
BsonDocument The other document.
Returns
- Bson
Document The document (so method calls can be chained).
Merge(BsonDocument, bool)
Merges another document into this one, specifying whether existing elements are overwritten.
Parameters
document
BsonDocument The other document.
overwriteExistingElements
boolWhether to overwrite existing elements.
Returns
- Bson
Document The document (so method calls can be chained).
Remove(string)
Removes an element from this document (if duplicate element names are allowed then all elements with this name will be removed).
Parameters
name
stringThe name of the element to remove.
RemoveAt(int)
Removes an element from this document.
Parameters
index
intThe zero based index of the element to remove.
RemoveElement(BsonElement)
Removes an element from this document.
Parameters
element
BsonElement The element to remove.
Set(int, BsonValue)
Sets the value of an element.
Parameters
index
intThe zero based index of the element whose value is to be set.
value
BsonValue The new value.
Returns
- Bson
Document The document (so method calls can be chained).
Set(string, BsonValue)
Sets the value of an element (an element will be added if no element with this name is found).
Parameters
Returns
- Bson
Document The document (so method calls can be chained).
SetElement(BsonElement)
Sets an element of the document (replaces any existing element with the same name or adds a new element if an element with the same name is not found).
Parameters
element
BsonElement The new element.
Returns
- Bson
Document The document.
SetElement(int, BsonElement)
Sets an element of the document (replacing the existing element at that position).
Parameters
index
intThe zero based index of the element to replace.
element
BsonElement The new element.
Returns
- Bson
Document The document.
ThrowIfDisposed()
Throws if disposed.
Exceptions
TryGetElement(string, out BsonElement)
Tries to get an element of this document.
Parameters
name
stringThe name of the element.
value
BsonElement The element.
Returns
- bool
True if an element with that name was found.
TryGetValue(string, out BsonValue)
Tries to get the value of an element of this document.
Parameters
Returns
- bool
True if an element with that name was found.