XmlQualifiedName ExportStructMapping(StructMapping mapping, string ns) {
if (mapping.TypeDesc.IsRoot) return ExportRootMapping(mapping);
XmlSchemaComplexType type = (XmlSchemaComplexType)types[mapping];
if (type == null) {
if (!mapping.IncludeInSchema) throw new InvalidOperationException(Res.GetString(Res.XmlSoapCannotIncludeInSchema, mapping.TypeDesc.Name));
CheckForDuplicateType(mapping.TypeName, mapping.Namespace);
type = new XmlSchemaComplexType();
type.Name = mapping.TypeName;
types.Add(mapping, type);
AddSchemaItem(type, mapping.Namespace, ns);
type.IsAbstract = mapping.TypeDesc.IsAbstract;
if (mapping.BaseMapping != null && mapping.BaseMapping.IncludeInSchema) {
XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension();
extension.BaseTypeName = ExportStructMapping(mapping.BaseMapping, mapping.Namespace);
XmlSchemaComplexContent model = new XmlSchemaComplexContent();
model.Content = extension;
type.ContentModel = model;
}
ExportTypeMembers(type, mapping.Members, mapping.Namespace);
ExportDerivedMappings(mapping);
}
else {
AddSchemaImport(mapping.Namespace, ns);
}
return new XmlQualifiedName(type.Name, mapping.Namespace);
}