System.Xml.Serialization.ListMap.GetSchemaArrayName C# (CSharp) Method

GetSchemaArrayName() public method

public GetSchemaArrayName ( ) : string
return string
		public string GetSchemaArrayName ()
		{
			XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) _itemInfo[0];
			if (einfo.MappedType != null) return TypeTranslator.GetArrayName (einfo.MappedType.XmlType);
			else return TypeTranslator.GetArrayName (einfo.TypeData.XmlType);
		}

Usage Example

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));
            }
        }
All Usage Examples Of System.Xml.Serialization.ListMap::GetSchemaArrayName