46 lines
2.2 KiB
C#
46 lines
2.2 KiB
C#
using adas_core.Domain.Enums;
|
|
using adas_core.Domain.Models.MongoModels;
|
|
using adas_core.Infrastructure.Utils.MongoMaps.Interfaz;
|
|
using MongoDB.Bson;
|
|
using MongoDB.Bson.Serialization;
|
|
using MongoDB.Bson.Serialization.Serializers;
|
|
|
|
namespace adas_core.Infrastructure.Utils.MongoMaps;
|
|
|
|
public class DisplayHomeConfigContributor : IEntityMapContributor
|
|
{
|
|
public void RegisterMaps()
|
|
{
|
|
if (!BsonClassMap.IsClassMapRegistered(typeof(CardConfig)))
|
|
BsonClassMap.RegisterClassMap<CardConfig>(cm =>
|
|
{
|
|
cm.AutoMap();
|
|
cm.MapIdMember(c => c.Id).SetElementName("_id");
|
|
cm.MapMember(c => c.Rows).SetDefaultValue(new List<RowCardConfig>());
|
|
});
|
|
|
|
if (!BsonClassMap.IsClassMapRegistered(typeof(RowCardConfig)))
|
|
BsonClassMap.RegisterClassMap<RowCardConfig>(cm =>
|
|
{
|
|
cm.AutoMap();
|
|
cm.MapMember(c => c.Cells).SetDefaultValue(new List<Cell>());
|
|
cm.MapMember(c => c.GrowPriority).SetDefaultValue(1);
|
|
cm.MapMember(c => c.Border).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.BorderRadius).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.Title).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.Size).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.MarginTop).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.MarginBottom).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.MarginLeft).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.MarginRight).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.BgColor).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.PaddingTop).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.PaddingBottom).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.PaddingLeft).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.PaddingRight).SetIgnoreIfNull(true);
|
|
cm.MapMember(c => c.Type)
|
|
.SetDefaultValue(DisplayConfigEnums.CellType.Default)
|
|
.SetSerializer(new EnumSerializer<DisplayConfigEnums.CellType>(BsonType.String));
|
|
});
|
|
}
|
|
} |