src/Inflatable/BaseClasses/MappingBaseClass.cs
/// <summary>
/// Reduces this instance based on parent mapping properties.
/// </summary>
/// <param name="parentMapping">The parent mapping.</param>
/// <param name="logger">The logger.</param>
Reduces this instance based on parent mapping properties.
Reduces this instance based on parent mapping properties .
public void Reduce(IMapping parentMapping, ILogger logger)
        {
            if (parentMapping is null)
                return;
            var IsDebug = logger?.IsEnabled(Serilog.Events.LogEventLevel.Debug) ?? false;
            for (var x = 0; x < parentMapping.ReferenceProperties.Count; ++x)
            {
                var ReferenceProperty1 = parentMapping.ReferenceProperties[x];
                for (var y = 0; 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 < parentMapping.MapProperties.Count; ++x)
            {
                var ReferenceProperty1 = parentMapping.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 < parentMapping.ManyToManyProperties.Count; ++x)
            {
                var ReferenceProperty1 = parentMapping.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 < parentMapping.ManyToOneProperties.Count; ++x)
            {
                var ReferenceProperty1 = parentMapping.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;
                    }
                }
            }
        }
public void Reduce ( IMapping parentMapping , ILogger logger ) { if ( parentMapping is null ) return ; var IsDebug = logger ? . IsEnabled ( Serilog . Events . LogEventLevel . Debug ) ?? false ; for ( var x = 0 ; x < parentMapping . ReferenceProperties . Count ; ++ x ) { var ReferenceProperty1 = parentMapping . ReferenceProperties [ x ] ; for ( var y = 0 ; y < ReferenceProperties . Count ; ++ y ) { var ReferenceProperty2 = ReferenceProperties [ y ] ; if ( ReferenceProperty1 . Similar ( ReferenceProperty2 ) ) { if ( IsDebug ) logger ? . Debug ( " " , ReferenceProperty2 . Name , ObjectType . Name ) ; ReferenceProperties . Remove ( ReferenceProperty2 ) ; -- y ; } } } for ( var x = 0 ; x < parentMapping . MapProperties . Count ; ++ x ) { var ReferenceProperty1 = parentMapping . MapProperties [ x ] ; for ( var y = x + 1 ; y < MapProperties . Count ; ++ y ) { var ReferenceProperty2 = MapProperties [ y ] ; if ( ReferenceProperty1 . Similar ( ReferenceProperty2 ) ) { if ( IsDebug ) logger ? . Debug ( " " , ReferenceProperty2 . Name , ObjectType . Name ) ; MapProperties . Remove ( ReferenceProperty2 ) ; -- y ; } } } for ( var x = 0 ; x < parentMapping . ManyToManyProperties . Count ; ++ x ) { var ReferenceProperty1 = parentMapping . ManyToManyProperties [ x ] ; for ( var y = x + 1 ; y < ManyToManyProperties . Count ; ++ y ) { var ReferenceProperty2 = ManyToManyProperties [ y ] ; if ( ReferenceProperty1 . Similar ( ReferenceProperty2 ) ) { if ( IsDebug ) logger ? . Debug ( " " , ReferenceProperty2 . Name , ObjectType . Name ) ; ManyToManyProperties . Remove ( ReferenceProperty2 ) ; -- y ; } } } for ( var x = 0 ; x < parentMapping . ManyToOneProperties . Count ; ++ x ) { var ReferenceProperty1 = parentMapping . ManyToOneProperties [ x ] ; for ( var y = x + 1 ; y < ManyToOneProperties . Count ; ++ y ) { var ReferenceProperty2 = ManyToOneProperties [ y ] ; if ( ReferenceProperty1 . Similar ( ReferenceProperty2 ) ) { if ( IsDebug ) logger ? . Debug ( " " , ReferenceProperty2 . Name , ObjectType . Name ) ; ManyToOneProperties . Remove ( ReferenceProperty2 ) ; -- y ; } } } }
Reduces this instance based on parent mapping properties.
Reduces this instance based on parent mapping properties .
parentMapping
IMapping
The parent mapping.
The parent mapping .
logger
ILogger
None