src/Shared/EntityFramework/Core/SchemaObjectModel/StructuredType.cs
// <summary>
// Determine if a cycle exists in the type hierarchy: use two pointers to
// walk the chain, if one catches up with the other, we have a cycle.
// </summary>
// <returns> true if a cycle exists in the type hierarchy, false otherwise </returns>
Determine if a cycle exists in the type hierarchy: use two pointers to
walk the chain, if one catches up with the other, we have a cycle.
Determine if a cycle exists in the type hierarchy : use two pointers to walk the chain if one catches up with the other we have a cycle .
private bool CheckForInheritanceCycle()
        {
            var baseType = BaseType;
            Debug.Assert(baseType != null);
            var ref1 = baseType;
            var ref2 = baseType;
            do
            {
                ref2 = ref2.BaseType;
                if (ReferenceEquals(ref1, ref2))
                {
                    return true;
                }
                if (ref1 == null)
                {
                    return false;
                }
                ref1 = ref1.BaseType;
                if (ref2 != null)
                {
                    ref2 = ref2.BaseType;
                }
            }
            while (ref2 != null);
            return false;
        }
private bool CheckForInheritanceCycle ( ) { var baseType = BaseType ; Debug . Assert ( baseType != null ) ; var ref1 = baseType ; var ref2 = baseType ; do { ref2 = ref2 . BaseType ; if ( ReferenceEquals ( ref1 , ref2 ) ) { return true ; } if ( ref1 == null ) { return false ; } ref1 = ref1 . BaseType ; if ( ref2 != null ) { ref2 = ref2 . BaseType ; } } while ( ref2 != null ) ; return false ; }
Determine if a cycle exists in the type hierarchy: use two pointers to
walk the chain, if one catches up with the other, we have a cycle.
Determine if a cycle exists in the type hierarchy : use two pointers to walk the chain if one catches up with the other we have a cycle .
true if a cycle exists in the type hierarchy, false otherwise
true if a cycle exists in the type hierarchy false otherwise