System.Xml.Schema.BaseProcessor.AddToTable C# (CSharp) Method

AddToTable() protected method

protected AddToTable ( XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item ) : void
table XmlSchemaObjectTable
qname XmlQualifiedName
item XmlSchemaObject
return void
        protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) {
            if (qname.Name.Length == 0) {
                return;
            }
            XmlSchemaObject existingObject = (XmlSchemaObject)table[qname];
            
            if (existingObject != null) {
                if (existingObject == item) { 
                    return;
                }
                string code = Res.Sch_DupGlobalElement; 
                if (item is XmlSchemaAttributeGroup) {
                    string ns = nameTable.Add(qname.Namespace);
                    if (Ref.Equal(ns, NsXml)) { //Check for xml namespace
                        XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
                        XmlSchemaObject builtInAttributeGroup = schemaForXmlNS.AttributeGroups[qname];
                        if ((object)existingObject == (object)builtInAttributeGroup) {
                            table.Insert(qname, item);
                            return;
                        }
                        else if ((object)item == (object)builtInAttributeGroup) { //trying to overwrite customer's component with built-in, ignore built-in
                            return;
                        }
                    }
                    else if (IsValidAttributeGroupRedefine(existingObject, item)){ //check for redefines
                        table.Insert(qname, item);
                        return;
                    }
                    code = Res.Sch_DupAttributeGroup;
                } 
                else if (item is XmlSchemaAttribute) {
                    string ns = nameTable.Add(qname.Namespace);
                    if (Ref.Equal(ns, NsXml)) {
                        XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
                        XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname];
                        if ((object)existingObject == (object)builtInAttribute) { //replace built-in one
                            table.Insert(qname, item);
                            return;
                        }
                        else if ((object)item == (object)builtInAttribute) { //trying to overwrite customer's component with built-in, ignore built-in
                            return;
                        }
                    }
                    code = Res.Sch_DupGlobalAttribute;
                } 
                else if (item is XmlSchemaSimpleType) {
                    if (IsValidTypeRedefine(existingObject, item)) {
                        table.Insert(qname, item);
                        return;
                    }
                    code = Res.Sch_DupSimpleType;
                } 
                else if (item is XmlSchemaComplexType) {
                    if (IsValidTypeRedefine(existingObject, item)) {
                        table.Insert(qname, item);
                        return;
                    }
                    code = Res.Sch_DupComplexType;
                }
                else if (item is XmlSchemaGroup) {
                    if (IsValidGroupRedefine(existingObject, item)){ //check for redefines
                        table.Insert(qname, item);
                        return;
                    }
                    code = Res.Sch_DupGroup;
                } 
                else if (item is XmlSchemaNotation) {
                    code = Res.Sch_DupNotation;
                }
                else if (item is XmlSchemaIdentityConstraint) {
                    code = Res.Sch_DupIdentityConstraint;
                }
                else {
                    Debug.Assert(item is XmlSchemaElement);
                }
                SendValidationEvent(code, qname.ToString(), item);
            } 
            else {
                table.Add(qname, item);
            }
        }