|
Currently, we allow default Serializers to be registered for all types in the current AppDomain. We also allow Default values to be configured for a field on a per class basis. For example:
BsonClassMap.RegisterClassMap<SomeClass>(x =>
|
{
|
x.AutoMap();
|
x.MapField(y => y.SomeProperty).SetDefaultValue(new SomeOtherClass());
|
});
|
The ability to call SetDefaultValue for a particular type (in this case, SomeOtherClass) for all references to the type within the current AppDomain would be helpful in ensuring incorrect or null values do not get written to the database (or deserialized from the database) if a SetDefaultValue is forgotten in a BsonClassMap call.
Something similar to the way a BsonSerializer is registered, like:
BsonSerializer.RegisterDefaultValue(typeof(SomeOtherClass), () => new SomeOtherClass());
|
|