public override object Deserialize(
BsonReader bsonReader,
Type nominalType,
Type actualType,
IBsonSerializationOptions options)
{
if (nominalType != typeof(Image))
{
var message = string.Format("Nominal type must be Image, not {0}.", nominalType.FullName);
throw new ArgumentException(message, "nominalType");
}
if (actualType != typeof(Image))
{
var message = string.Format("Actual type must be Image, not {0}.", actualType.FullName);
throw new ArgumentException(message, "actualType");
}
var bsonType = bsonReader.GetCurrentBsonType();
if (bsonType == BsonType.Null)
{
bsonReader.ReadNull();
return null;
}
else
{
var message = string.Format("BsonType must be Null, not {0}.", bsonType);
throw new FileFormatException(message);
}
}