/// <summary> /// Reduces this instance and removes duplicate properties /// </summary> /// <param name="logger">The logger.</param> public void Reduce(ILogger logger) { var IsDebug = logger?.IsEnabled(Serilog.Events.LogEventLevel.Debug) ?? false; for (var x = 0; x < IDProperties.Count; ++x) { var IDProperty1 = IDProperties[x]; for (var y = x + 1; y < IDProperties.Count; ++y) { var IDProperty2 = IDProperties[y]; if (IDProperty1 == IDProperty2) { if (IsDebug) { logger?.Debug("Found duplicate ID and removing {Name:l} from mapping {Mapping:l}", IDProperty2.Name, ObjectType.Name); } IDProperties.Remove(IDProperty2); --y; } } } for (var x = 0; x < ReferenceProperties.Count; ++x) { var ReferenceProperty1 = ReferenceProperties[x]; for (var y = x + 1; y < ReferenceProperties.Count; ++y) { var ReferenceProperty2 = ReferenceProperties[y]; if (ReferenceProperty1.Similar(ReferenceProperty2)) { if (IsDebug) { logger?.Debug("Found duplicate reference and removing {Name:l} from mapping {Mapping:l}", ReferenceProperty2.Name, ObjectType.Name); } ReferenceProperties.Remove(ReferenceProperty2); --y; } } } for (var x = 0; x < MapProperties.Count; ++x) { var ReferenceProperty1 = MapProperties[x]; for (var y = x + 1; y < MapProperties.Count; ++y) { var ReferenceProperty2 = MapProperties[y]; if (ReferenceProperty1.Similar(ReferenceProperty2)) { if (IsDebug) { logger?.Debug("Found duplicate map and removing {Name:l} from mapping {Mapping:l}", ReferenceProperty2.Name, ObjectType.Name); } MapProperties.Remove(ReferenceProperty2); --y; } } } for (var x = 0; x < ManyToManyProperties.Count; ++x) { var ReferenceProperty1 = ManyToManyProperties[x]; for (var y = x + 1; y < ManyToManyProperties.Count; ++y) { var ReferenceProperty2 = ManyToManyProperties[y]; if (ReferenceProperty1.Similar(ReferenceProperty2)) { if (IsDebug) { logger?.Debug("Found duplicate many to many and removing {Name:l} from mapping {Mapping:l}", ReferenceProperty2.Name, ObjectType.Name); } ManyToManyProperties.Remove(ReferenceProperty2); --y; } } } for (var x = 0; x < ManyToOneProperties.Count; ++x) { var ReferenceProperty1 = ManyToOneProperties[x]; for (var y = x + 1; y < ManyToOneProperties.Count; ++y) { var ReferenceProperty2 = ManyToOneProperties[y]; if (ReferenceProperty1.Similar(ReferenceProperty2)) { if (IsDebug) { logger?.Debug("Found duplicate many to one and removing {Name:l} from mapping {Mapping:l}", ReferenceProperty2.Name, ObjectType.Name); } ManyToOneProperties.Remove(ReferenceProperty2); --y; } } } }