Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2004-06-22 13:51:50 +0400
committerLluis Sanchez <lluis@novell.com>2004-06-22 13:51:50 +0400
commit360208e6549dcf8471325ad5e5f01f8417f205f2 (patch)
treed4103c1c1c438a390ab4a359194d7141418f02e8 /mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
parentad194e0f9604ebf3b221bef00bb56eac44cd8221 (diff)
* ReflectionHelper.cs: Correctly detect private types.
* XmlCodeExporter.cs: Implemented missing method. * XmlSchemaImporter.cs: Allow import of root primitive types. svn path=/trunk/mcs/; revision=30104
Diffstat (limited to 'mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs')
-rw-r--r--mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs45
1 files changed, 30 insertions, 15 deletions
diff --git a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
index aab75cb73a3..74490082f7a 100644
--- a/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
+++ b/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs
@@ -143,7 +143,8 @@ namespace System.Xml.Serialization {
}
else
{
- if (!LocateElement (name, out qname, out stype)) return null;
+ if (!LocateElement (name, out qname, out stype) || stype == null)
+ return null;
}
XmlTypeMapping map = GetRegisteredTypeMapping (qname);
@@ -186,17 +187,7 @@ namespace System.Xml.Serialization {
// Does not have the requested base type.
// Then, get/create a map for that base type.
- XmlTypeMapping baseMap;
- if (!encodedFormat)
- {
- if (auxXmlRefImporter == null) auxXmlRefImporter = new XmlReflectionImporter ();
- baseMap = auxXmlRefImporter.ImportTypeMapping (baseType);
- }
- else
- {
- if (auxSoapRefImporter == null) auxSoapRefImporter = new SoapReflectionImporter ();
- baseMap = auxSoapRefImporter.ImportTypeMapping (baseType);
- }
+ XmlTypeMapping baseMap = ReflectType (baseType, null);
// Add this map as a derived map of the base map
@@ -335,7 +326,13 @@ namespace System.Xml.Serialization {
{
XmlQualifiedName qname;
XmlSchemaType stype;
- if (!LocateElement (name, out qname, out stype)) return null;
+ if (!LocateElement (name, out qname, out stype)) return null;
+
+ if (stype == null) {
+ // Importing a primitive type
+ TypeData td = TypeTranslator.GetPrimitiveTypeData (qname.Name);
+ return ReflectType (td.Type, name.Namespace);
+ }
XmlTypeMapping map = GetRegisteredTypeMapping (qname);
if (map != null) return map;
@@ -365,8 +362,13 @@ namespace System.Xml.Serialization {
}
else
{
- if (elem.SchemaTypeName.IsEmpty) return false;
- if (elem.SchemaTypeName.Namespace == XmlSchema.Namespace) return false;
+ if (elem.SchemaTypeName.IsEmpty) return false;
+
+ if (elem.SchemaTypeName.Namespace == XmlSchema.Namespace) {
+ qname = elem.SchemaTypeName;
+ return true;
+ }
+
object type = schemas.Find (elem.SchemaTypeName, typeof (XmlSchemaComplexType));
if (type == null) type = schemas.Find (elem.SchemaTypeName, typeof (XmlSchemaSimpleType));
if (type == null) throw new InvalidOperationException ("Schema type '" + elem.SchemaTypeName + "' not found");
@@ -1597,6 +1599,19 @@ namespace System.Xml.Serialization {
}
return grp;
+ }
+
+ XmlTypeMapping ReflectType (Type type, string ns)
+ { if (!encodedFormat)
+ {
+ if (auxXmlRefImporter == null) auxXmlRefImporter = new XmlReflectionImporter ();
+ return auxXmlRefImporter.ImportTypeMapping (type, ns);
+ }
+ else
+ {
+ if (auxSoapRefImporter == null) auxSoapRefImporter = new SoapReflectionImporter ();
+ return auxSoapRefImporter.ImportTypeMapping (type, ns);
+ }
}