public void SerializeProperty( BsonWriter bsonWriter, object obj, BsonPropertyMap propertyMap ) { var value = (BsonRegularExpression) propertyMap.Getter(obj); if (value == null) { bsonWriter.WriteNull(propertyMap.ElementName); } else { bsonWriter.WriteRegularExpression(propertyMap.ElementName, value.Pattern, value.Options); } }