Mongo 驱动程序的旧实现导致了这种代码:
public object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType)
{
if (nominalType == typeof(T))
{
if (typeof(V) == typeof(string))
return _deSerializeFunc(bsonReader.ReadString());
else if (typeof(V) == typeof(int))
return _deSerializeFunc(bsonReader.ReadInt32());
else if (typeof(V) == typeof(double))
return _deSerializeFunc(bsonReader.ReadDouble());
else if (typeof(V) == typeof(decimal))
return _deSerializeFunc((decimal)bsonReader.ReadDouble());
}
return null;
}
新界面完全不同。如何使用这个新接口开始实现以前的代码?
public object Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
{