internal void CheckDuplicateElement(XmlSchemaElement element, string elementNs) { if ((element != null) && ((element.Parent != null) && (element.Parent is XmlSchema))) { XmlSchemaObjectTable elements = null; if ((this.Schema != null) && (this.Schema.TargetNamespace == elementNs)) { XmlSchemas.Preprocess(this.Schema); elements = this.Schema.Elements; } else if (this.Schemas != null) { elements = this.Schemas.GlobalElements; } else { return; } foreach (XmlSchemaElement element2 in elements.Values) { if ((element2.Name == element.Name) && (element2.QualifiedName.Namespace == elementNs)) { if (!this.Match(element2, element)) { throw new InvalidOperationException(Res.GetString("XmlSerializableRootDupName", new object[] { this.getSchemaMethod.DeclaringType.FullName, element2.Name, elementNs })); } break; } } } }
internal override void ImportDerivedTypes(XmlQualifiedName baseName) { foreach (XmlSchema schema in Schemas) { if (Schemas.IsReference(schema)) { continue; } if (XmlSchemas.IsDataSet(schema)) { continue; } XmlSchemas.Preprocess(schema); foreach (object item in schema.SchemaTypes.Values) { if (item is XmlSchemaType) { XmlSchemaType type = (XmlSchemaType)item; if (type.DerivedFrom == baseName) { ImportType(type.QualifiedName, false); } } } } }
internal void CheckDuplicateElement(XmlSchemaElement element, string elementNs) { if (element == null) { return; } // only check duplicate definitions for top-level element if (element.Parent == null || !(element.Parent is XmlSchema)) { return; } XmlSchemaObjectTable elements = null; if (Schema != null && Schema.TargetNamespace == elementNs) { XmlSchemas.Preprocess(Schema); elements = Schema.Elements; } else if (Schemas != null) { elements = Schemas.GlobalElements; } else { return; } foreach (XmlSchemaElement e in elements.Values) { if (e.Name == element.Name && e.QualifiedName.Namespace == elementNs) { if (Match(e, element)) { return; } // XmlSerializableRootDupName=Cannot reconcile schema for '{0}'. Please use [XmlRoot] attribute to change name or namepace of the top-level element to avoid duplicate element declarations: element name='{1} namespace='{2}'. throw new InvalidOperationException(SR.Format(SR.XmlSerializableRootDupName, _getSchemaMethod.DeclaringType.FullName, e.Name, elementNs)); } } }
internal override void ImportDerivedTypes(XmlQualifiedName baseName) { foreach (XmlSchema schema in base.Schemas) { if (!base.Schemas.IsReference(schema) && !XmlSchemas.IsDataSet(schema)) { XmlSchemas.Preprocess(schema); foreach (object obj2 in schema.SchemaTypes.Values) { if (obj2 is XmlSchemaType) { XmlSchemaType type = (XmlSchemaType)obj2; if (type.DerivedFrom == baseName) { this.ImportType(type.QualifiedName, false); } } } } } }