Show / Hide Table of Contents

Class BSONDocument

Represents a BSON document

Inheritance
System.Object
BSONDocument
Query
Update
Implements
IJSONWritable
System.Collections.Generic.IEnumerable<BSONElement>
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)
Namespace: NFX.Serialization.BSON
Assembly: NFX.dll
Syntax
public class BSONDocument : IJSONWritable, IEnumerable<BSONElement>, IEnumerable

Constructors

BSONDocument()

Create an empty document

Declaration
public BSONDocument()

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
Type Description
BSONElement

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
Type Description
BSONElement

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
Type Description
BSONDocument

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
Type Description
BSONDocument

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
Type Description
BSONDocument

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

IJSONWritable
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T>)
CollectionUtils.ForEach<T>(IEnumerable<T>, Action<T, Int32>)
CollectionUtils.SkipLast<T>(IEnumerable<T>)
CollectionUtils.SkipLast<T>(IEnumerable<T>, Int32)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMin<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>)
CollectionUtils.FirstMax<TResult, TComparand>(IEnumerable<TResult>, Func<TResult, TComparand>, out TComparand)
CollectionUtils.FirstOrAnyOrDefault<TResult>(IEnumerable<TResult>, Func<TResult, Boolean>)
CollectionUtils.Distinct<TResult, TKey>(IEnumerable<TResult>, Func<TResult, TKey>)
MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
LookAheadExtensions.AsLookAheadEnumerable<T>(IEnumerable<T>)
BSONExtensions.Add(BSONDocument, String, Object, Boolean, Boolean)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX