GetSchemaArrayName() public method

public GetSchemaArrayName ( ) : string
return string
Example #1
0
        XmlQualifiedName ExportArraySchema(XmlTypeMapping map, string defaultNamespace)
        {
            ListMap lmap = (ListMap)map.ObjectMap;

            if (encodedFormat)
            {
                string name, ns, schemaNs;
                lmap.GetArrayType(-1, out name, out ns);
                if (ns == XmlSchema.Namespace)
                {
                    schemaNs = defaultNamespace;
                }
                else
                {
                    schemaNs = ns;
                }

                if (IsMapExported(map))
                {
                    return(new XmlQualifiedName(lmap.GetSchemaArrayName(), schemaNs));
                }
                SetMapExported(map);

                XmlSchema            schema = GetSchema(schemaNs);
                XmlSchemaComplexType stype  = new XmlSchemaComplexType();
                stype.Name = lmap.GetSchemaArrayName();
                schema.Items.Add(stype);

                XmlSchemaComplexContent content = new XmlSchemaComplexContent();
                content.IsMixed    = false;
                stype.ContentModel = content;

                XmlSchemaComplexContentRestriction rest = new XmlSchemaComplexContentRestriction();
                content.Content   = rest;
                rest.BaseTypeName = new XmlQualifiedName("Array", XmlSerializer.EncodingNamespace);
                XmlSchemaAttribute at = new XmlSchemaAttribute();
                rest.Attributes.Add(at);
                at.RefName = new XmlQualifiedName("arrayType", XmlSerializer.EncodingNamespace);

                XmlAttribute arrayType = Document.CreateAttribute("arrayType", XmlSerializer.WsdlNamespace);
                arrayType.Value        = ns + (ns != "" ? ":" : "") + name;
                at.UnhandledAttributes = new XmlAttribute [] { arrayType };
                ImportNamespace(schema, XmlSerializer.WsdlNamespace);

                XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo)lmap.ItemInfo[0];
                if (einfo.MappedType != null)
                {
                    switch (einfo.TypeData.SchemaType)
                    {
                    case SchemaTypes.Enum:
                        ExportEnumSchema(einfo.MappedType);
                        break;

                    case SchemaTypes.Array:
                        ExportArraySchema(einfo.MappedType, schemaNs);
                        break;

                    case SchemaTypes.Class:
                        ExportClassSchema(einfo.MappedType);
                        break;
                    }
                }

                return(new XmlQualifiedName(lmap.GetSchemaArrayName(), schemaNs));
            }
            else
            {
                if (IsMapExported(map))
                {
                    return(new XmlQualifiedName(map.XmlType, map.XmlTypeNamespace));
                }

                SetMapExported(map);
                XmlSchema            schema = GetSchema(map.XmlTypeNamespace);
                XmlSchemaComplexType stype  = new XmlSchemaComplexType();
                stype.Name = map.ElementName;
                schema.Items.Add(stype);

                XmlSchemaParticle spart = GetSchemaArrayElement(schema, lmap.ItemInfo);
                if (spart is XmlSchemaChoice)
                {
                    stype.Particle = spart;
                }
                else
                {
                    XmlSchemaSequence seq = new XmlSchemaSequence();
                    seq.Items.Add(spart);
                    stype.Particle = seq;
                }

                return(new XmlQualifiedName(map.XmlType, map.XmlTypeNamespace));
            }
        }
        private XmlQualifiedName ExportArraySchema(XmlTypeMapping map, string defaultNamespace)
        {
            ListMap listMap = (ListMap)map.ObjectMap;

            if (this.encodedFormat)
            {
                string str;
                string text;
                listMap.GetArrayType(-1, out str, out text);
                string text2;
                if (text == "http://www.w3.org/2001/XMLSchema")
                {
                    text2 = defaultNamespace;
                }
                else
                {
                    text2 = text;
                }
                if (this.IsMapExported(map))
                {
                    return(new XmlQualifiedName(listMap.GetSchemaArrayName(), text2));
                }
                this.SetMapExported(map);
                XmlSchema            schema = this.GetSchema(text2);
                XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType();
                xmlSchemaComplexType.Name = listMap.GetSchemaArrayName();
                schema.Items.Add(xmlSchemaComplexType);
                XmlSchemaComplexContent xmlSchemaComplexContent = new XmlSchemaComplexContent();
                xmlSchemaComplexContent.IsMixed   = false;
                xmlSchemaComplexType.ContentModel = xmlSchemaComplexContent;
                XmlSchemaComplexContentRestriction xmlSchemaComplexContentRestriction = new XmlSchemaComplexContentRestriction();
                xmlSchemaComplexContent.Content = xmlSchemaComplexContentRestriction;
                xmlSchemaComplexContentRestriction.BaseTypeName = new XmlQualifiedName("Array", "http://schemas.xmlsoap.org/soap/encoding/");
                XmlSchemaAttribute xmlSchemaAttribute = new XmlSchemaAttribute();
                xmlSchemaComplexContentRestriction.Attributes.Add(xmlSchemaAttribute);
                xmlSchemaAttribute.RefName = new XmlQualifiedName("arrayType", "http://schemas.xmlsoap.org/soap/encoding/");
                XmlAttribute xmlAttribute = this.Document.CreateAttribute("arrayType", "http://schemas.xmlsoap.org/wsdl/");
                xmlAttribute.Value = text + ((!(text != string.Empty)) ? string.Empty : ":") + str;
                xmlSchemaAttribute.UnhandledAttributes = new XmlAttribute[]
                {
                    xmlAttribute
                };
                this.ImportNamespace(schema, "http://schemas.xmlsoap.org/wsdl/");
                XmlTypeMapElementInfo xmlTypeMapElementInfo = (XmlTypeMapElementInfo)listMap.ItemInfo[0];
                if (xmlTypeMapElementInfo.MappedType != null)
                {
                    switch (xmlTypeMapElementInfo.TypeData.SchemaType)
                    {
                    case SchemaTypes.Enum:
                        this.ExportEnumSchema(xmlTypeMapElementInfo.MappedType);
                        break;

                    case SchemaTypes.Array:
                        this.ExportArraySchema(xmlTypeMapElementInfo.MappedType, text2);
                        break;

                    case SchemaTypes.Class:
                        this.ExportClassSchema(xmlTypeMapElementInfo.MappedType);
                        break;
                    }
                }
                return(new XmlQualifiedName(listMap.GetSchemaArrayName(), text2));
            }
            else
            {
                if (this.IsMapExported(map))
                {
                    return(new XmlQualifiedName(map.XmlType, map.XmlTypeNamespace));
                }
                this.SetMapExported(map);
                XmlSchema            schema2 = this.GetSchema(map.XmlTypeNamespace);
                XmlSchemaComplexType xmlSchemaComplexType2 = new XmlSchemaComplexType();
                xmlSchemaComplexType2.Name = map.ElementName;
                schema2.Items.Add(xmlSchemaComplexType2);
                XmlSchemaParticle schemaArrayElement = this.GetSchemaArrayElement(schema2, listMap.ItemInfo);
                if (schemaArrayElement is XmlSchemaChoice)
                {
                    xmlSchemaComplexType2.Particle = schemaArrayElement;
                }
                else
                {
                    xmlSchemaComplexType2.Particle = new XmlSchemaSequence
                    {
                        Items =
                        {
                            schemaArrayElement
                        }
                    };
                }
                return(new XmlQualifiedName(map.XmlType, map.XmlTypeNamespace));
            }
        }