using adas_core.Domain.Models.MongoModels; using adas_core.Infrastructure.Utils.MongoMaps.Interfaz; using MongoDB.Bson.Serialization; namespace adas_core.Infrastructure.Utils.MongoMaps; /// /// Represents a contributor that participates in entity mapping for observation units by implementing the contract. /// /// /// Used to register or supply mapping logic specific to observation unit entities within the entity mapping framework. /// public class ObsUnitMapContributor : IEntityMapContributor { /// /// Registers BSON class maps for and types if they have not already been registered, configuring how their members are serialized to MongoDB documents. /// public void RegisterMaps() { if (!BsonClassMap.IsClassMapRegistered(typeof(ConfigUnits))) BsonClassMap.RegisterClassMap(cm => { cm.AutoMap(); cm.MapIdMember(c => c.Id).SetElementName("_id").SetDefaultValue(string.Empty); cm.MapMember(c => c.Items).SetIgnoreIfNull(true); }); if (!BsonClassMap.IsClassMapRegistered(typeof(ConfigUnitItem))) BsonClassMap.RegisterClassMap(cm => { cm.AutoMap(); cm.GetMemberMap(c => c.Code).SetIgnoreIfNull(true); cm.GetMemberMap(c => c.Value).SetIgnoreIfNull(true); }); } }