rama creada apartir de master en j
This commit is contained in:
@@ -7,34 +7,40 @@ using MongoDB.Bson.Serialization;
|
||||
|
||||
namespace adas_core.Infrastructure.Utils.MongoMaps;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a map contributor that provides mapping configuration for communication flow entities by implementing the <see cref="IEntityMapContributor"/> interface.
|
||||
/// </summary>
|
||||
public class ComunicationFlowMapContributor : IEntityMapContributor
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers BSON class maps for the application's MongoDB-serialized types, including <see cref="Message"/>, <see cref="Queue"/>, <see cref="ApiRequest"/>, <see cref="AdmPanelRequest"/>, <see cref="ApiClients"/>, and <see cref="VideoDto"/>, applying custom mapping rules such as unmapping the <c>Operation</c> member on <see cref="Message"/> and ignoring null values for <c>ObsertationData</c> on <see cref="AdmPanelRequest"/>. Each type is only registered if a class map has not already been registered, preventing duplicate registration.
|
||||
/// </summary>
|
||||
public void RegisterMaps()
|
||||
{
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(Message)))
|
||||
BsonClassMap.RegisterClassMap<Message>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.UnmapMember(c => c.Operation);
|
||||
});
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(Queue)))
|
||||
BsonClassMap.RegisterClassMap<Queue>(cm => { cm.AutoMap(); });
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(ApiRequest)))
|
||||
BsonClassMap.RegisterClassMap<ApiRequest>(cm => { cm.AutoMap(); });
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(AdmPanelRequest)))
|
||||
BsonClassMap.RegisterClassMap<AdmPanelRequest>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.GetMemberMap(c => c.ObsertationData).SetIgnoreIfNull(true);
|
||||
});
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(ApiClients)))
|
||||
BsonClassMap.RegisterClassMap<ApiClients>(cm => { cm.AutoMap(); });
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(VideoDto)))
|
||||
BsonClassMap.RegisterClassMap<VideoDto>(cm => { cm.AutoMap(); });
|
||||
}
|
||||
{
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(Message)))
|
||||
BsonClassMap.RegisterClassMap<Message>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.UnmapMember(c => c.Operation);
|
||||
});
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(Queue)))
|
||||
BsonClassMap.RegisterClassMap<Queue>(cm => { cm.AutoMap(); });
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(ApiRequest)))
|
||||
BsonClassMap.RegisterClassMap<ApiRequest>(cm => { cm.AutoMap(); });
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(AdmPanelRequest)))
|
||||
BsonClassMap.RegisterClassMap<AdmPanelRequest>(cm =>
|
||||
{
|
||||
cm.AutoMap();
|
||||
cm.GetMemberMap(c => c.ObsertationData).SetIgnoreIfNull(true);
|
||||
});
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(ApiClients)))
|
||||
BsonClassMap.RegisterClassMap<ApiClients>(cm => { cm.AutoMap(); });
|
||||
|
||||
if (!BsonClassMap.IsClassMapRegistered(typeof(VideoDto)))
|
||||
BsonClassMap.RegisterClassMap<VideoDto>(cm => { cm.AutoMap(); });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user