rama creada apartir de master en j

This commit is contained in:
jrojas
2026-06-26 10:29:23 +02:00
parent 319fd3dfb0
commit c1517fda87
2810 changed files with 1927392 additions and 25392 deletions
@@ -6,37 +6,48 @@ using LightBeacon = adas_core.Domain.Models.MongoModels.LightBeacon;
namespace adas_core.Infrastructure.Utils.MongoMaps;
/// <summary>
/// Represents a map contributor that participates in entity mapping operations
/// for beacon-related entities.
/// </summary>
/// <remarks>
/// Implements the <see cref="IEntityMapContributor"/> interface to contribute
/// beacon-specific mapping logic.
/// </remarks>
public class BeaconMapContributor : IEntityMapContributor
{
/// <summary>
/// Registers BSON class maps for <see cref="LightBeacon"/>, <see cref="Options"/>, and <see cref="LightBeaconAbstract"/> types to configure their MongoDB serialization. Each registration is skipped if a class map for the type has already been registered, applying default values, element name mappings, and ignore-if-null settings to the respective members.
/// </summary>
public void RegisterMaps()
{
if (!BsonClassMap.IsClassMapRegistered(typeof(LightBeacon)))
BsonClassMap.RegisterClassMap<LightBeacon>(cm =>
{
cm.AutoMap();
cm.MapIdMember(c => c.Id).SetElementName("_id");
cm.MapMember(c => c.Type).SetDefaultValue(string.Empty);
cm.MapMember(c => c.Name).SetDefaultValue(string.Empty);
cm.MapMember(c => c.Options).SetDefaultValue(new Options());
cm.MapMember(c => c.InUse).SetIgnoreIfNull(true).SetIsRequired(false);
});
if (!BsonClassMap.IsClassMapRegistered(typeof(Options)))
BsonClassMap.RegisterClassMap<Options>(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.Url).SetIgnoreIfNull(true);
cm.MapMember(c => c.Port).SetIgnoreIfNull(true);
cm.MapMember(c => c.Password).SetIgnoreIfNull(true);
cm.MapMember(c => c.Emulate).SetDefaultValue(false);
});
if (!BsonClassMap.IsClassMapRegistered(typeof(LightBeaconAbstract)))
BsonClassMap.RegisterClassMap<LightBeaconAbstract>(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.Host);
cm.MapMember(c => c.Password);
});
}
{
if (!BsonClassMap.IsClassMapRegistered(typeof(LightBeacon)))
BsonClassMap.RegisterClassMap<LightBeacon>(cm =>
{
cm.AutoMap();
cm.MapIdMember(c => c.Id).SetElementName("_id");
cm.MapMember(c => c.Type).SetDefaultValue(string.Empty);
cm.MapMember(c => c.Name).SetDefaultValue(string.Empty);
cm.MapMember(c => c.Options).SetDefaultValue(new Options());
cm.MapMember(c => c.InUse).SetIgnoreIfNull(true).SetIsRequired(false);
});
if (!BsonClassMap.IsClassMapRegistered(typeof(Options)))
BsonClassMap.RegisterClassMap<Options>(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.Url).SetIgnoreIfNull(true);
cm.MapMember(c => c.Port).SetIgnoreIfNull(true);
cm.MapMember(c => c.Password).SetIgnoreIfNull(true);
cm.MapMember(c => c.Emulate).SetDefaultValue(false);
});
if (!BsonClassMap.IsClassMapRegistered(typeof(LightBeaconAbstract)))
BsonClassMap.RegisterClassMap<LightBeaconAbstract>(cm =>
{
cm.AutoMap();
cm.MapMember(c => c.Host);
cm.MapMember(c => c.Password);
});
}
}