rama creada apartir de master en j
This commit is contained in:
@@ -4,36 +4,45 @@ using MongoDB.Bson.Serialization;
|
||||
|
||||
namespace adas_core.Infrastructure.Utils.MongoMaps;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a contributor that participates in entity mapping, providing header-related mapping logic.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Implements the <see cref="IEntityMapContributor"/> interface to contribute mapping behavior within the entity mapping pipeline.
|
||||
/// </remarks>
|
||||
public class HeaderMapContributor : IEntityMapContributor
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers BSON class maps for the <see cref="HeaderConfig"/> type and its nested <see cref="HeaderConfig.HeaderItem"/> type with the MongoDB BsonClassMap serializer, configuring default values and null-ignore behavior for their members. Registration is performed only if a class map for the corresponding type has not already been registered, preventing duplicate registrations.
|
||||
/// </summary>
|
||||
public void RegisterMaps()
|
||||
{
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(HeaderConfig)))
|
||||
BsonClassMap.RegisterClassMap<HeaderConfig>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.MapMember(c => c.PartnerLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.CompanyLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.CenterLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.MeddisLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.UnitName).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Cameras).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Sensors).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Fullscreen).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Sounds).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Sidebar).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.CurrentDateTime).SetDefaultValue(new HeaderConfig.HeaderItem())
|
||||
.SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.SectionTitle).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
});
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(HeaderConfig.HeaderItem)))
|
||||
BsonClassMap.RegisterClassMap<HeaderConfig.HeaderItem>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.MapMember(c => c.LogoUrl).SetDefaultValue(() => null)
|
||||
.SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.IsVisible).SetDefaultValue(true);
|
||||
});
|
||||
}
|
||||
{
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(HeaderConfig)))
|
||||
BsonClassMap.RegisterClassMap<HeaderConfig>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.MapMember(c => c.PartnerLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.CompanyLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.CenterLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.MeddisLogo).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.UnitName).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Cameras).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Sensors).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Fullscreen).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Sounds).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.Sidebar).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.CurrentDateTime).SetDefaultValue(new HeaderConfig.HeaderItem())
|
||||
.SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.SectionTitle).SetDefaultValue(new HeaderConfig.HeaderItem()).SetIgnoreIfNull(true);
|
||||
});
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(HeaderConfig.HeaderItem)))
|
||||
BsonClassMap.RegisterClassMap<HeaderConfig.HeaderItem>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.MapMember(c => c.LogoUrl).SetDefaultValue(() => null)
|
||||
.SetIgnoreIfNull(true);
|
||||
cm.MapMember(c => c.IsVisible).SetDefaultValue(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user