src/Misc/EFTools/EntityDesign/UI/Views/Dialogs/ReferentialConstraintDialog.cs
// <summary>
//     shows a warning dialog if a dependent property is used more than once
// </summary>
// <returns>whether all dependent properties are used at most once</returns>
shows a warning dialog if a dependent property is used more than once
shows a warning dialog if a dependent property is used more than once
private bool CheckDepPropMappedOnlyOnce()
        {
            var depPropsAlreadyUsed = new HashSet<Symbol>();
            var dupeProps = new HashSet<Symbol>(); 
            foreach (var mli in MappingList)
            {
                if (mli.IsValidPrincipalKey)
                {
                    if (mli.DependentProperty != null)
                    {
                        if (depPropsAlreadyUsed.Contains(mli.DependentProperty))
                        {
                            if (!dupeProps.Contains(mli.DependentProperty))
                            {
                                dupeProps.Add(mli.DependentProperty);
                            }
                        }
                        else
                        {
                            depPropsAlreadyUsed.Add(mli.DependentProperty);
                        }
                    }
                }
            }
            if (0 == dupeProps.Count)
            {
                return true;
            }
            else
            {
                var listOfDupeProps = new StringBuilder();
                var isFirst = true;
                foreach (var prop in dupeProps)
                {
                    if (!isFirst)
                    {
                        listOfDupeProps.Append(CultureInfo.CurrentCulture.TextInfo.ListSeparator);
                    }
                    isFirst = false;
                    listOfDupeProps.Append(prop.ToDisplayString());
                }
                VsUtils.ShowMessageBox(
                    PackageManager.Package,
                    string.Format(
                        CultureInfo.CurrentCulture, DialogsResource.RefConstraintDialog_DependentPropMappedMultipleTimes, listOfDupeProps),
                    OLEMSGBUTTON.OLEMSGBUTTON_OK,
                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                    OLEMSGICON.OLEMSGICON_WARNING);
                return false;
            }
        }
private bool CheckDepPropMappedOnlyOnce ( ) { var depPropsAlreadyUsed = new HashSet < Symbol > ( ) ; var dupeProps = new HashSet < Symbol > ( ) ; foreach ( var mli in MappingList ) { if ( mli . IsValidPrincipalKey ) { if ( mli . DependentProperty != null ) { if ( depPropsAlreadyUsed . Contains ( mli . DependentProperty ) ) { if ( ! dupeProps . Contains ( mli . DependentProperty ) ) { dupeProps . Add ( mli . DependentProperty ) ; } } else { depPropsAlreadyUsed . Add ( mli . DependentProperty ) ; } } } } if ( 0 == dupeProps . Count ) { return true ; } else { var listOfDupeProps = new StringBuilder ( ) ; var isFirst = true ; foreach ( var prop in dupeProps ) { if ( ! isFirst ) { listOfDupeProps . Append ( CultureInfo . CurrentCulture . TextInfo . ListSeparator ) ; } isFirst = false ; listOfDupeProps . Append ( prop . ToDisplayString ( ) ) ; } VsUtils . ShowMessageBox ( PackageManager . Package , string . Format ( CultureInfo . CurrentCulture , DialogsResource . RefConstraintDialog_DependentPropMappedMultipleTimes , listOfDupeProps ) , OLEMSGBUTTON . OLEMSGBUTTON_OK , OLEMSGDEFBUTTON . OLEMSGDEFBUTTON_FIRST , OLEMSGICON . OLEMSGICON_WARNING ) ; return false ; } }
shows a warning dialog if a dependent property is used more than once
shows a warning dialog if a dependent property is used more than once
// used to identify duplicated properties in error message // if property is duplicated it may be duplicated more than once // only add to this list once // dupeProps contains the list of dependent properties mapped more than once // if dupeProps contains any properties display them in the warning and return false // construct list of duplicated Properties // display warning dialog
whether all dependent properties are used at most once
whether all dependent properties are used at most once