Source/NFX/Serialization/BSON/BSONSerializer.cs
/// <summary>
/// Adds a field named TypeIDFieldName with the type id of the object instance, force=true to emit the field even if it is a known type.
/// Returns true if type id element was added
/// </summary>
Adds a field named TypeIDFieldName with the type id of the object instance, force=true to emit the field even if it is a known type.
Returns true if type id element was added
Adds a field named TypeIDFieldName with the type id of the object instance force = true to emit the field even if it is a known type . Returns true if type id element was added
public virtual bool AddTypeIDField(BSONDocument doc, IBSONSerializable parent, IBSONSerializable self, object ctx, bool force = false)
    {
      if (doc==null) return false;
      if (self==null) return false;
      var add = force || parent==null;
      var t = self.GetType();
      if (!add)
        add = !parent.IsKnownTypeForBSONDeserialization(t);
      if (add)
      {
        var id = BSONSerializableAttribute.GetGuidTypeAttribute<object, BSONSerializableAttribute>(t)
                                          .TypeGuid;
        var telm = new BSONBinaryElement(TypeIDFieldName, new BSONBinary(BSONBinaryType.UUID, id.ToByteArray()));
        doc.Set( telm );
        return true;
      }
      return false;
    }
public virtual bool AddTypeIDField ( BSONDocument doc , IBSONSerializable parent , IBSONSerializable self , object ctx , bool force = false ) { if ( doc == null ) return false ; if ( self == null ) return false ; var add = force || parent == null ; var t = self . GetType ( ) ; if ( ! add ) add = ! parent . IsKnownTypeForBSONDeserialization ( t ) ; if ( add ) { var id = BSONSerializableAttribute . GetGuidTypeAttribute < object , BSONSerializableAttribute > ( t ) . TypeGuid ; var telm = new BSONBinaryElement ( TypeIDFieldName , new BSONBinary ( BSONBinaryType . UUID , id . ToByteArray ( ) ) ) ; doc . Set ( telm ) ; return true ; } return false ; }
Adds a field named TypeIDFieldName with the type id of the object instance, force=true to emit the field even if it is a known type.
Adds a field named TypeIDFieldName with the type id of the object instance force = true to emit the field even if it is a known type .
doc
BSONDocument
parent
IBSONSerializable
self
IBSONSerializable
ctx
object
force
bool