Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using adas_core.Domain.Models.MongoModels;
|
||||
using adas_core.Infrastructure.Utils.MongoMaps.Interfaz;
|
||||
using adas_core.module.LightBeacons.Devices;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using LightBeacon = adas_core.Domain.Models.MongoModels.LightBeacon;
|
||||
|
||||
namespace adas_core.Infrastructure.Utils.MongoMaps;
|
||||
|
||||
public class BeaconMapContributor : IEntityMapContributor
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user