System.Data.XSDSchema.HandleParticle C# (CSharp) Method

HandleParticle() private method

private HandleParticle ( XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, bool isBase ) : void
pt System.Xml.Schema.XmlSchemaParticle
table DataTable
tableChildren System.Collections.ArrayList
isBase bool
return void
        internal void HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, bool isBase)
        {
            XmlSchemaObjectCollection items = GetParticleItems(pt);

            if (items == null)
                return;

            foreach (XmlSchemaAnnotated item in items)
            {
                XmlSchemaElement el = item as XmlSchemaElement;
                if (el != null)
                {
                    if (FromInference && pt is XmlSchemaChoice && pt.MaxOccurs > decimal.One && (el.SchemaType is XmlSchemaComplexType))
                        el.MaxOccurs = pt.MaxOccurs;


                    DataTable child = null;
                    // to decide if element is our table, we need to match both name and ns 
                    // 286043 - SQL BU Defect Tracking
                    if (((el.Name == null) && (el.RefName.Name == table.EncodedTableName && el.RefName.Namespace == table.Namespace)) ||
                        (IsTable(el) && el.Name == table.TableName))
                    {
                        if (FromInference)
                        {
                            child = HandleTable(el);
                            Debug.Assert(child == table, "table not the same");
                        }
                        else
                        {
                            child = table;
                        }
                    }
                    else
                    {
                        child = HandleTable(el);
                        if (child == null && FromInference && el.Name == table.TableName)
                        {
                            child = table;
                        }
                    }

                    if (child == null)
                    {
                        if (!FromInference || el.Name != table.TableName)
                        {// check is required to support 1.1 inference behavior
                            HandleElementColumn(el, table, isBase);
                        }
                    }
                    else
                    {
                        DataRelation relation = null;
                        if (el.Annotation != null)
                            HandleRelations(el.Annotation, true);

                        DataRelationCollection childRelations = table.ChildRelations;
                        for (int j = 0; j < childRelations.Count; j++)
                        {
                            if (!childRelations[j].Nested)
                                continue;

                            if (child == childRelations[j].ChildTable)
                                relation = childRelations[j];
                        }

                        if (relation == null)
                        {
                            tableChildren.Add(child);// how about prefix for this?
                            if (FromInference && table.UKColumnPositionForInference == -1)
                            { // this is done for Inference
                                int ukColumnPosition = -1;
                                foreach (DataColumn dc in table.Columns)
                                {
                                    if (dc.ColumnMapping == MappingType.Element)
                                        ukColumnPosition++;
                                }
                                table.UKColumnPositionForInference = ukColumnPosition + 1; // since it starts from 
                            }
                        }
                    }
                }
                else
                {
                    HandleParticle((XmlSchemaParticle)item, table, tableChildren, isBase);
                }
            }
            return;
        }