public override object Deserialize(
BsonReader bsonReader,
Type nominalType,
Type actualType,
IBsonSerializationOptions options)
{
if (!nominalType.IsInterface)
{
var message = string.Format("Nominal type must be an interface, not {0}.", nominalType.FullName);
throw new ArgumentException(message, "nominalType");
}
if (actualType == nominalType)
{
var message = string.Format("Unable to determine actual type of object to deserialize. NominalType is the interface {0}.", nominalType);
throw new Exception(message);
}
var serializer = BsonSerializer.LookupSerializer(actualType);
return serializer.Deserialize(bsonReader, nominalType, actualType, options);
}