Source/NFX/Serialization/BSON/BSONSerializer.cs
/// <summary>
/// Deserilizes an instance from BSONDocument.
/// If instance is not pre-allocated (result=null) tries to create a type
/// decorated with BSONSerializableAttribute(guid)
/// </summary>
Deserilizes an instance from BSONDocument.
If instance is not pre-allocated (result=null) tries to create a type
decorated with BSONSerializableAttribute(guid)
Deserilizes an instance from BSONDocument . If instance is not pre - allocated ( result = null ) tries to create a type decorated with BSONSerializableAttribute ( guid )
public IBSONDeserializable Deserialize(BSONDocument doc, IBSONDeserializable result = null)
    {
      object ctx = null;
      if (result==null)
      {
        var telm = doc[TypeIDFieldName] as BSONBinaryElement;
        if (telm==null)
          throw new BSONException(StringConsts.BSON_DESERIALIZER_DOC_MISSING_TID_ERROR.Args(TypeIDFieldName));
        var tid = telm.Value.Data.AsGUID(Guid.Empty);
        if (tid==Guid.Empty)
          throw new BSONException(StringConsts.BSON_DESERIALIZER_DOC_TID_GUID_ERROR.Args(TypeIDFieldName, telm.Value));
        try
        {
          var tresult = m_Resolver.Resolve(tid);
          result = SerializationUtils.MakeNewObjectInstance(tresult) as IBSONDeserializable;
          if (result==null) throw new BSONException("result isnot IBSONDeserializable");
        }
        catch(Exception error)
        {
          throw new BSONException(StringConsts.BSON_DESERIALIZER_MAKE_TYPE_ERROR.Args(tid, error.ToMessageWithType()), error);
        }
      }
      try
      {
        result.DeserializeFromBSON(this, doc, ref ctx);
      }
      catch(Exception error)
      {
        throw new BSONException(StringConsts.BSON_DESERIALIZER_DFB_ERROR.Args(error.ToMessageWithType()), error);
      }
      return result;
    }
public IBSONDeserializable Deserialize ( BSONDocument doc , IBSONDeserializable result = null ) { object ctx = null ; if ( result == null ) { var telm = doc [ TypeIDFieldName ] as BSONBinaryElement ; if ( telm == null ) throw new BSONException ( StringConsts . BSON_DESERIALIZER_DOC_MISSING_TID_ERROR . Args ( TypeIDFieldName ) ) ; var tid = telm . Value . Data . AsGUID ( Guid . Empty ) ; if ( tid == Guid . Empty ) throw new BSONException ( StringConsts . BSON_DESERIALIZER_DOC_TID_GUID_ERROR . Args ( TypeIDFieldName , telm . Value ) ) ; try { var tresult = m_Resolver . Resolve ( tid ) ; result = SerializationUtils . MakeNewObjectInstance ( tresult ) as IBSONDeserializable ; if ( result == null ) throw new BSONException ( " " ) ; } catch ( Exception error ) { throw new BSONException ( StringConsts . BSON_DESERIALIZER_MAKE_TYPE_ERROR . Args ( tid , error . ToMessageWithType ( ) ) , error ) ; } } try { result . DeserializeFromBSON ( this , doc , ref ctx ) ; } catch ( Exception error ) { throw new BSONException ( StringConsts . BSON_DESERIALIZER_DFB_ERROR . Args ( error . ToMessageWithType ( ) ) , error ) ; } return result ; }
Deserilizes an instance from BSONDocument.
Deserilizes an instance from BSONDocument .
doc
BSONDocument
result
IBSONDeserializable