System.Xml.Serialization.XmlSchemaImporter.IsCyclicReferencedType C# (CSharp) Method

IsCyclicReferencedType() private method

private IsCyclicReferencedType ( XmlSchemaElement element, List identifiers ) : bool
element System.Xml.Schema.XmlSchemaElement
identifiers List
return bool
        private bool IsCyclicReferencedType(XmlSchemaElement element, List<string> identifiers)
        {
            if (!element.RefName.IsEmpty)
            {
                XmlSchemaElement refElement = FindElement(element.RefName);
                string refElementIdentifier = CodeIdentifier.MakeValid(Accessor.UnescapeName(refElement.Name));
                foreach (string identifier in identifiers)
                {
                    if (refElementIdentifier == identifier)
                    {
                        return true;
                    }
                }
                identifiers.Add(refElementIdentifier);

                XmlSchemaType refType = refElement.SchemaType;
                if (refType is XmlSchemaComplexType)
                {
                    TypeItems items = GetTypeItems(refType);
                    if ((items.Particle is XmlSchemaSequence || items.Particle is XmlSchemaAll) && items.Particle.Items.Count == 1 && items.Particle.Items[0] is XmlSchemaElement)
                    {
                        XmlSchemaElement innerRefElement = (XmlSchemaElement)items.Particle.Items[0];
                        if (innerRefElement.IsMultipleOccurrence)
                        {
                            return IsCyclicReferencedType(innerRefElement, identifiers);
                        }
                    }
                }
            }
            return false;
        }