Class BSONDocument
Represents a BSON document
Inheritance
System.Object
BSONDocument
Implements
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.dll
Syntax
public class BSONDocument : IJSONWritable, IEnumerable<BSONElement>, IEnumerable
Constructors
BSONDocument()
Declaration
BSONDocument(Stream)
Deserializes BSON document from stream containing BSON-encoded data
Declaration
public BSONDocument(Stream stream)
Parameters
Type |
Name |
Description |
System.IO.Stream |
stream |
|
BSONDocument(String, Boolean, TemplateArg[])
Creates an instance of the document from JSON template with parameters populated from args optionally caching the template internal
representation. Do not cache templates that change often
Declaration
public BSONDocument(string template, bool cacheTemplate, params TemplateArg[] args)
Parameters
Type |
Name |
Description |
System.String |
template |
|
System.Boolean |
cacheTemplate |
|
TemplateArg[] |
args |
|
Fields
ARG_TPL_PREFIX
Declaration
public const string ARG_TPL_PREFIX = "$$"
Field Value
Type |
Description |
System.String |
|
IDX_THRESHOLD
Declaration
public const int IDX_THRESHOLD = 6
Field Value
Type |
Description |
System.Int32 |
|
Properties
ByteSize
Recalculates the BSON binary size of this document expressed in bytes
Declaration
public int ByteSize { get; }
Property Value
Type |
Description |
System.Int32 |
|
Count
Returns the number of BSONElements in this document
Declaration
public int Count { get; }
Property Value
Type |
Description |
System.Int32 |
|
Item[Int32]
Returns BSONElement by index or null if index is out of bounds
Declaration
public BSONElement this[int idx] { get; }
Parameters
Type |
Name |
Description |
System.Int32 |
idx |
|
Property Value
Item[String]
Returns BSONElement by name or null if not found
Declaration
public BSONElement this[string name] { get; }
Parameters
Type |
Name |
Description |
System.String |
name |
|
Property Value
Methods
Delete(String)
Deletes an element by name returning true if it was found and deleted
Declaration
public bool Delete(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Boolean |
|
FromArray(Byte[])
Creates document from array containing BSON-encoded data
Declaration
public static BSONDocument FromArray(byte[] content)
Parameters
Type |
Name |
Description |
System.Byte[] |
content |
|
Returns
GetEnumerator()
Declaration
public IEnumerator<BSONElement> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<BSONElement> |
|
IndexOfName(String)
Returns index of named BSONElement or -1 if it does not exist
Declaration
public int IndexOfName(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Int32 |
|
Set(BSONElement, out Boolean, Int32)
Inserts BSONElement into document
Declaration
public BSONDocument Set(BSONElement value, out bool added, int atIndex = -1)
Parameters
Type |
Name |
Description |
BSONElement |
value |
|
System.Boolean |
added |
|
System.Int32 |
atIndex |
|
Returns
Set(BSONElement, Int32)
Inserts BSONElement into document
Declaration
public BSONDocument Set(BSONElement value, int atIndex = -1)
Parameters
Type |
Name |
Description |
BSONElement |
value |
|
System.Int32 |
atIndex |
|
Returns
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
TryGetObjectValueOf(String)
Tries to get an element by name and if found returns its object value, null otherwise
Declaration
public object TryGetObjectValueOf(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Object |
|
WriteAsBSON(Stream)
Serializes this document into BSON-format stream
Declaration
public void WriteAsBSON(Stream stream)
Parameters
Type |
Name |
Description |
System.IO.Stream |
stream |
|
WriteAsBSONToNewArray()
Serializes BSON document to byte[]
Declaration
public byte[] WriteAsBSONToNewArray()
Returns
Type |
Description |
System.Byte[] |
|
WriteAsJSON(TextWriter, Int32, JSONWritingOptions)
Serializes this dosument into a TextWriter - this method is used by JSON serializer(JSONWriter)
Declaration
public void WriteAsJSON(TextWriter wri, int nestingLevel, JSONWritingOptions options = null)
Parameters
Type |
Name |
Description |
System.IO.TextWriter |
wri |
|
System.Int32 |
nestingLevel |
|
JSONWritingOptions |
options |
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type |
Description |
System.Collections.IEnumerator |
|
Implements
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Extension Methods