src/Misc/EFTools/EntityDesignModel/ModelHelper.cs
/// <summary>
///     Looks for a cycle in the ComplexTypes graph that includes baseComplexType using DFS algorithm
/// </summary>
/// <param name="baseComplexType"></param>
/// <param name="currentComplexType"></param>
/// <param name="visited"></param>
/// <returns></returns>
Looks for a cycle in the ComplexTypes graph that includes baseComplexType using DFS algorithm
Looks for a cycle in the ComplexTypes graph that includes baseComplexType using DFS algorithm
private static bool ContainsCircularComplexTypeDefinition(
            ComplexType baseComplexType, ComplexType currentComplexType, HashSet<ComplexType> visited)
        {
            if (visited.Contains(currentComplexType))
            {
                return false;
            }
            if (baseComplexType == currentComplexType)
            {
                return true;
            }
            visited.Add(currentComplexType);
            foreach (var property in currentComplexType.Properties())
            {
                var complexProperty = property as ComplexConceptualProperty;
                if (complexProperty != null
                    && complexProperty.ComplexType.Status == BindingStatus.Known)
                {
                    if (ContainsCircularComplexTypeDefinition(baseComplexType, complexProperty.ComplexType.Target, visited))
                    {
                        return true;
                    }
                }
            }
            return false;
        }
private static bool ContainsCircularComplexTypeDefinition ( ComplexType baseComplexType , ComplexType currentComplexType , HashSet < ComplexType > visited ) { if ( visited . Contains ( currentComplexType ) ) { return false ; } if ( baseComplexType == currentComplexType ) { return true ; } visited . Add ( currentComplexType ) ; foreach ( var property in currentComplexType . Properties ( ) ) { var complexProperty = property as ComplexConceptualProperty ; if ( complexProperty != null && complexProperty . ComplexType . Status == BindingStatus . Known ) { if ( ContainsCircularComplexTypeDefinition ( baseComplexType , complexProperty . ComplexType . Target , visited ) ) { return true ; } } } return false ; }
Looks for a cycle in the ComplexTypes graph that includes baseComplexType using DFS algorithm
Looks for a cycle in the ComplexTypes graph that includes baseComplexType using DFS algorithm
None
baseComplexType
ComplexType
None
currentComplexType
ComplexType
None
visited
HashSet<ComplexType>
None