MongoDB.Bson.Serialization.Serializers.BsonValueCSharpNullSerializer.Deserialize C# (CSharp) Метод

Deserialize() публичный Метод

Deserializes an object from a BsonReader.
public Deserialize ( MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options ) : object
bsonReader MongoDB.Bson.IO.BsonReader The BsonReader.
nominalType System.Type The nominal type of the object.
actualType System.Type The actual type of the object.
options IBsonSerializationOptions The serialization options.
Результат object
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            var bsonType = bsonReader.GetCurrentBsonType();
            if (bsonType == BsonType.Document && IsCSharpNullRepresentation(bsonReader))
            {
                // if IsCSharpNullRepresentation returns true it will have consumed the document representing C# null
                return null;
            }

            // handle BSON null for backward compatibility with existing data (new data would have _csharpnull)
            if (bsonType == BsonType.Null && (nominalType != typeof(BsonValue) && nominalType != typeof(BsonNull)))
            {
                bsonReader.ReadNull();
                return null;
            }

            var serializer = BsonSerializer.LookupSerializer(actualType);
            return serializer.Deserialize(bsonReader, nominalType, actualType, options);
        }