public override object Deserialize(
BsonReader bsonReader,
Type nominalType,
Type actualType,
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(Uri));
BsonType bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
{
case BsonType.Null:
bsonReader.ReadNull();
return null;
case BsonType.String:
return new Uri(bsonReader.ReadString(), UriKind.RelativeOrAbsolute);
default:
var message = string.Format("Cannot deserialize Uri from BsonType {0}.", bsonType);
throw new Exception(message);
}
}