public override object Deserialize(
BsonReader bsonReader,
Type nominalType,
Type actualType,
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(System.Drawing.Size));
var bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
{
case BsonType.Document:
bsonReader.ReadStartDocument();
var width = bsonReader.ReadInt32("Width");
var height = bsonReader.ReadInt32("Height");
bsonReader.ReadEndDocument();
return new System.Drawing.Size(width, height);
default:
var message = string.Format("Cannot deserialize Size from BsonType {0}.", bsonType);
throw new FileFormatException(message);
}
}