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

GatherGroupChoices() private method

private GatherGroupChoices ( XmlSchemaParticle particle, NameTable choiceElements, string identifier, string ns, bool &needExplicitOrder, bool allowDuplicates ) : bool
particle System.Xml.Schema.XmlSchemaParticle
choiceElements NameTable
identifier string
ns string
needExplicitOrder bool
allowDuplicates bool
return bool
        private bool GatherGroupChoices(XmlSchemaParticle particle, NameTable choiceElements, string identifier, string ns, ref bool needExplicitOrder, bool allowDuplicates)
        {
            if (particle is XmlSchemaGroupRef)
            {
                XmlSchemaGroupRef refGroup = (XmlSchemaGroupRef)particle;
                if (!refGroup.RefName.IsEmpty)
                {
                    AddReference(refGroup.RefName, GroupsInUse, SR.XmlCircularGroupReference);
                    if (GatherGroupChoices(FindGroup(refGroup.RefName), choiceElements, identifier, refGroup.RefName.Namespace, ref needExplicitOrder, allowDuplicates))
                    {
                        RemoveReference(refGroup.RefName, GroupsInUse);
                        return true;
                    }
                    RemoveReference(refGroup.RefName, GroupsInUse);
                }
            }
            else if (particle is XmlSchemaGroupBase)
            {
                XmlSchemaGroupBase group = (XmlSchemaGroupBase)particle;
                bool groupRepeats = group.IsMultipleOccurrence;
                XmlSchemaAny any = null;
                bool duplicateElements = false;
                for (int i = 0; i < group.Items.Count; i++)
                {
                    object item = group.Items[i];
                    if (item is XmlSchemaGroupBase || item is XmlSchemaGroupRef)
                    {
                        if (GatherGroupChoices((XmlSchemaParticle)item, choiceElements, identifier, ns, ref needExplicitOrder, allowDuplicates))
                            groupRepeats = true;
                    }
                    else if (item is XmlSchemaAny)
                    {
                        if (GenerateOrder)
                        {
                            AddScopeElements(choiceElements, ImportAny((XmlSchemaAny)item, true, ns), ref duplicateElements, allowDuplicates);
                        }
                        else
                        {
                            any = (XmlSchemaAny)item;
                        }
                    }
                    else if (item is XmlSchemaElement)
                    {
                        XmlSchemaElement element = (XmlSchemaElement)item;
                        XmlSchemaElement headElement = GetTopLevelElement(element);
                        if (headElement != null)
                        {
                            XmlSchemaElement[] elements = GetEquivalentElements(headElement);
                            for (int j = 0; j < elements.Length; j++)
                            {
                                if (elements[j].IsMultipleOccurrence) groupRepeats = true;
                                AddScopeElement(choiceElements, ImportElement(elements[j], identifier, typeof(TypeMapping), null, elements[j].QualifiedName.Namespace, true), ref duplicateElements, allowDuplicates);
                            }
                        }
                        if (element.IsMultipleOccurrence) groupRepeats = true;
                        AddScopeElement(choiceElements, ImportElement(element, identifier, typeof(TypeMapping), null, element.QualifiedName.Namespace, false), ref duplicateElements, allowDuplicates);
                    }
                }
                if (any != null)
                {
                    AddScopeElements(choiceElements, ImportAny(any, true, ns), ref duplicateElements, allowDuplicates);
                }
                if (!groupRepeats && !(group is XmlSchemaChoice) && group.Items.Count > 1)
                {
                    groupRepeats = true;
                }
                return groupRepeats;
            }
            return false;
        }

Same methods

XmlSchemaImporter::GatherGroupChoices ( XmlSchemaGroup group, NameTable choiceElements, string identifier, string ns, bool &needExplicitOrder, bool allowDuplicates ) : bool