Class BSONElement
  
  Very base class for BSON elements
 
  
  
    Inheritance
    System.Object
    BSONElement
      
      
      
      
   
  
    Implements
    
    System.IConvertible
    
   
  
    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: NFX.dll
  Syntax
  
    public abstract class BSONElement : INamed, IConvertible, IJSONWritable
   
  Constructors
  
  
  
  
  BSONElement(Stream)
  
  
  Declaration
  
    protected BSONElement(Stream stream)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IO.Stream | 
        stream | 
         | 
      
    
  
  
  
  
  BSONElement(String)
  
  
  Declaration
  
    protected BSONElement(string name)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.String | 
        name | 
         | 
      
    
  
  Properties
  
  
  
  
  ByteSize
  Recalculates the BSON binary size of this document expressed in bytes
 
  
  Declaration
  
    public int ByteSize { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int32 | 
         | 
      
    
  
  
  
  
  ElementType
  Provides BSON classification of data type
 
  
  Declaration
  
    public abstract BSONElementType ElementType { get; }
   
  Property Value
  
  
  
  
  IsArrayElement
  Returns true when this element does not have a name - it is a part of the array
 
  
  Declaration
  
    public bool IsArrayElement { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  
  
  
  Name
  Return the name of this element. The name is immutable.
Check IaArrayElelemnt first, as this property can not be gotten for array elements
 
  
  Declaration
  
    public string Name { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.String | 
         | 
      
    
  
  
  
  
  ObjectValue
  Gets/sets the value of this element polymorphically
 
  
  Declaration
  
    public abstract object ObjectValue { get; set; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Object | 
         | 
      
    
  
  Methods
  
  
  
  
  GetElementFactory(BSONElementType)
  
  
  Declaration
  
    public static Func<Stream, BSONElement> GetElementFactory(BSONElementType bsonType)
   
  Parameters
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Func<System.IO.Stream, BSONElement> | 
         | 
      
    
  
  
  
  
  GetTypeCode()
  
  
  Declaration
  
    public TypeCode GetTypeCode()
   
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.TypeCode | 
         | 
      
    
  
  
  
  
  GetValueByteSize()
  Returns the size of this element in bytes
 
  
  Declaration
  
    protected abstract int GetValueByteSize()
   
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int32 | 
         | 
      
    
  
  
  
  
  MakeOfType(BSONElementType, String, Object)
  
  
  Declaration
  
    public static BSONElement MakeOfType(BSONElementType bsonType, string name, object value)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | BSONElementType | 
        bsonType | 
         | 
      
      
        | System.String | 
        name | 
         | 
      
      
        | System.Object | 
        value | 
         | 
      
    
  
  Returns
  
  
  
  
  ReadValueFromStream(Stream)
  Override to read element's value from stream
 
  
  Declaration
  
    protected abstract void ReadValueFromStream(Stream stream)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IO.Stream | 
        stream | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public bool ToBoolean(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public byte ToByte(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Byte | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public char ToChar(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Char | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public DateTime ToDateTime(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.DateTime | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public decimal ToDecimal(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Decimal | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public double ToDouble(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Double | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public short ToInt16(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int16 | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public int ToInt32(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int32 | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public long ToInt64(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int64 | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public sbyte ToSByte(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.SByte | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public float ToSingle(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Single | 
         | 
      
    
  
  
  
  
  ToString()
  
  
  Declaration
  
    public override string ToString()
   
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.String | 
         | 
      
    
  
  Overrides
  System.Object.ToString()
  
  
  
  
  
  
  Declaration
  
    public string ToString(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.String | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public object ToType(Type conversionType, IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Type | 
        conversionType | 
         | 
      
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Object | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public ushort ToUInt16(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.UInt16 | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public uint ToUInt32(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.UInt32 | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public ulong ToUInt64(IFormatProvider provider)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IFormatProvider | 
        provider | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.UInt64 | 
         | 
      
    
  
  
  
  
  WriteAsJSON(TextWriter, Int32, JSONWritingOptions)
  
  
  Declaration
  
    public virtual void WriteAsJSON(TextWriter wri, int nestingLevel, JSONWritingOptions options = null)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IO.TextWriter | 
        wri | 
         | 
      
      
        | System.Int32 | 
        nestingLevel | 
         | 
      
      
        | JSONWritingOptions | 
        options | 
         | 
      
    
  
  
  
  
  WriteToStream(Stream)
  
  
  Declaration
  
    protected void WriteToStream(Stream stream)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IO.Stream | 
        stream | 
         | 
      
    
  
  
  
  
  WriteValueToStream(Stream)
  Override to write this element into a stream
 
  
  Declaration
  
    protected abstract void WriteValueToStream(Stream stream)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.IO.Stream | 
        stream | 
         | 
      
    
  
  Implements
  
  
      System.IConvertible
  
  
  Extension Methods