public override object Deserialize(
BsonReader bsonReader,
Type nominalType,
Type actualType,
IBsonSerializationOptions options)
{
VerifyTypes(nominalType, actualType, typeof(BsonDateTime));
var bsonType = bsonReader.GetCurrentBsonType();
switch (bsonType)
{
case BsonType.DateTime:
var millisecondsSinceEpoch = bsonReader.ReadDateTime();
return new BsonDateTime(millisecondsSinceEpoch);
default:
var message = string.Format("Cannot deserialize BsonDateTime from BsonType {0}.", bsonType);
throw new Exception(message);
}
}