System.Xml.Serialization.SoapSchemaImporter.ImportElementType C# (CSharp) Method

ImportElementType() private method

private ImportElementType ( XmlSchemaElement element, string ns ) : TypeMapping
element System.Xml.Schema.XmlSchemaElement
ns string
return TypeMapping
        TypeMapping ImportElementType(XmlSchemaElement element, string ns) {
            TypeMapping mapping;
            if (!element.SchemaTypeName.IsEmpty)
                mapping = ImportType(element.SchemaTypeName, false);
            else if (element.SchemaType != null) {
                XmlQualifiedName parentType = XmlSchemas.GetParentName(element);
                if (element.SchemaType is XmlSchemaComplexType) {
                    mapping = ImportType((XmlSchemaComplexType)element.SchemaType, ns, false);
                    if (!(mapping is ArrayMapping)) {
                        throw new InvalidOperationException(Res.GetString(Res.XmlInvalidSchemaElementType, parentType.Name, parentType.Namespace, element.Name));
                    }
                }
                else {
                    throw new InvalidOperationException(Res.GetString(Res.XmlInvalidSchemaElementType, parentType.Name, parentType.Namespace, element.Name));
                }
            }
            else if (!element.SubstitutionGroup.IsEmpty) {
                XmlQualifiedName parentType = XmlSchemas.GetParentName(element);
                throw new InvalidOperationException(Res.GetString(Res.XmlInvalidSubstitutionGroupUse, parentType.Name, parentType.Namespace));
            }
            else {
                XmlQualifiedName parentType = XmlSchemas.GetParentName(element);
                throw new InvalidOperationException(Res.GetString(Res.XmlElementMissingType, parentType.Name, parentType.Namespace, element.Name));
            }

            mapping.ReferencedByElement = true;

            return mapping;
        }