using adas_core.Domain.Models.MongoModels;
using adas_core.Infrastructure.Utils.MongoMaps.Interfaz;
using MongoDB.Bson.Serialization;
namespace adas_core.Infrastructure.Utils.MongoMaps;
///
/// Provides a standard implementation of the interface.
///
public class StandardMapContributor : IEntityMapContributor
{
///
/// Registers BSON class maps for and types
/// used during MongoDB serialization, skipping any types that are already registered. For
/// , several nullable UI configuration members are configured to be ignored
/// when null to avoid persisting default values.
///
public void RegisterMaps()
{
if (!BsonClassMap.IsClassMapRegistered(typeof(HistoricalConfigChanges)))
BsonClassMap.RegisterClassMap(cm =>
{
cm.AutoMap();
//cm.MapMember(c => c.Id)
// .SetSerializer(new ObjectIdSerializer(BsonType.String));
//cm.GetMemberMap(c => c.ConfigType)
// .SetSerializer(new NullableSerializer(new EnumSerializer(BsonType.String)));
});
if (!BsonClassMap.IsClassMapRegistered(typeof(UiFontData)))
BsonClassMap.RegisterClassMap(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.WidthStepBed).SetIgnoreIfNull(true);
cm.MapMember(c => c.HeightStepBed).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeValue).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeMediumValue).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeHeaderValue).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeLittleValue).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeMicroValue).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeNanoValue).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeLittleTextValue).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeName).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeLittleName).SetIgnoreIfNull(true);
cm.MapMember(c => c.FontSizeUnit).SetIgnoreIfNull(true);
cm.MapMember(c => c.BorderColor).SetIgnoreIfNull(true);
cm.MapMember(c => c.BackGroundColor).SetIgnoreIfNull(true);
cm.MapMember(c => c.BoxMarginTop).SetIgnoreIfNull(true);
cm.MapMember(c => c.BoxMarginBot).SetIgnoreIfNull(true);
cm.MapMember(c => c.BoxMarginLeft).SetIgnoreIfNull(true);
cm.MapMember(c => c.BoxMarginRight).SetIgnoreIfNull(true);
});
}
}