Source/NFX/Serialization/BSON/RowConverter.cs
/// <summary>
/// Converts BSON to CLR value 1:1, without type change
/// </summary>
Converts BSON to CLR value 1:1, without type change
Converts BSON to CLR value 1 : 1 without type change
protected virtual object DirectConvertBSONValue(BSONElement element, Func<BSONDocument, BSONElement, bool> filter = null)
        {
          if (element==null || element is BSONNullElement) return null;
          if (element.ElementType == BSONElementType.Document) return BSONDocumentToJSONMap(((BSONDocumentElement)element).Value, filter);
          if (element.ElementType == BSONElementType.Array)
          {
            var bsonArr = (BSONArrayElement)element;
            var lst = new List<object>();
            foreach(var elm in bsonArr.Value)
              lst.Add( DirectConvertBSONValue(elm, filter) );
            return lst.ToArray();
          }
          switch (element.ElementType)
          {
            case BSONElementType.ObjectID: return ((BSONObjectIDElement)element).Value.AsGDID;
            case BSONElementType.Binary: return ((BSONBinaryElement)element).Value.Data;
          }
          return element.ObjectValue;
        }
protected virtual object DirectConvertBSONValue ( BSONElement element , Func < BSONDocument , BSONElement , bool > filter = null ) { if ( element == null || element is BSONNullElement ) return null ; if ( element . ElementType == BSONElementType . Document ) return BSONDocumentToJSONMap ( ( ( BSONDocumentElement ) element ) . Value , filter ) ; if ( element . ElementType == BSONElementType . Array ) { var bsonArr = ( BSONArrayElement ) element ; var lst = new List < object > ( ) ; foreach ( var elm in bsonArr . Value ) lst . Add ( DirectConvertBSONValue ( elm , filter ) ) ; return lst . ToArray ( ) ; } switch ( element . ElementType ) { case BSONElementType . ObjectID : return ( ( BSONObjectIDElement ) element ) . Value . AsGDID ; case BSONElementType . Binary : return ( ( BSONBinaryElement ) element ) . Value . Data ; } return element . ObjectValue ; }
Converts BSON to CLR value 1:1, without type change
Converts BSON to CLR value 1 : 1 without type change
element
BSONElement
filter
Func<BSONDocument, BSONElement, bool>