public void DeserializeProperty( BsonReader bsonReader, object obj, BsonPropertyMap propertyMap ) { var bsonType = bsonReader.PeekBsonType(); BsonJavaScriptWithScope value; if (bsonType == BsonType.Null) { bsonReader.ReadNull(propertyMap.ElementName); value = null; } else { var code = bsonReader.ReadJavaScriptWithScope(propertyMap.ElementName); var scope = BsonDocument.ReadFrom(bsonReader); value = new BsonJavaScriptWithScope(code, scope); } propertyMap.Setter(obj, value); }