internal class XmlSerializableMapping : XmlTypeMapping
{
XmlSchema _schema;
-#if NET_2_0
+#if NET_2_0 && !MOONLIGHT
XmlSchemaComplexType _schemaType;
XmlQualifiedName _schemaTypeName;
#endif
- internal XmlSerializableMapping(string elementName, string ns, TypeData typeData, string xmlType, string xmlTypeNamespace)
+ internal XmlSerializableMapping(XmlRootAttribute root, string elementName, string ns, TypeData typeData, string xmlType, string xmlTypeNamespace)
: base(elementName, ns, typeData, xmlType, xmlTypeNamespace)
{
-#if NET_2_0
+#if NET_2_0 && !MOONLIGHT
XmlSchemaProviderAttribute schemaProvider = (XmlSchemaProviderAttribute) Attribute.GetCustomAttribute (typeData.Type, typeof (XmlSchemaProviderAttribute));
if (schemaProvider != null) {
String.Format ("Method {0}.{1}() specified by XmlSchemaProviderAttribute has invalid signature: return type must be compatible with System.Xml.XmlQualifiedName.", typeData.Type.Name, method));
// defaultNamespace at XmlReflectionImporter takes precedence for Namespace, but not for XsdTypeNamespace.
- UpdateRoot (new XmlQualifiedName (_schemaTypeName.Name, Namespace ?? _schemaTypeName.Namespace));
+ UpdateRoot (new XmlQualifiedName (root != null ? root.ElementName : _schemaTypeName.Name, root != null ? root.Namespace : Namespace ?? _schemaTypeName.Namespace));
XmlTypeNamespace = _schemaTypeName.Namespace;
XmlType = _schemaTypeName.Name;
return;
}
#endif
+#if NET_2_0 && !MOONLIGHT
IXmlSerializable serializable = (IXmlSerializable)Activator.CreateInstance (typeData.Type, true);
-#if NET_2_0
try {
_schema = serializable.GetSchema();
} catch (Exception) {
// LAMESPEC: .NET has a bad exception catch and swallows it silently.
}
#else
+ IXmlSerializable serializable = (IXmlSerializable)Activator.CreateInstance (typeData.Type);
_schema = serializable.GetSchema();
#endif
+#if !MOONLIGHT
if (_schema != null)
{
if (_schema.Id == null || _schema.Id.Length == 0)
throw new InvalidOperationException("Schema Id is missing. The schema returned from " + typeData.Type.FullName + ".GetSchema() must have an Id.");
}
+#endif
}
internal XmlSchema Schema
get { return _schema; }
}
-#if NET_2_0
+#if NET_2_0 && !MOONLIGHT
internal XmlSchemaType SchemaType {
get { return _schemaType; }
}
public void AddMember (XmlTypeMapMember member)
{
- member.GlobalIndex = _allMembers.Count;
+ // If GlobalIndex has not been set, set it now
+ if (member.GlobalIndex == -1)
+ member.GlobalIndex = _allMembers.Count;
+
_allMembers.Add (member);
if (!(member.DefaultValue is System.DBNull) && member.DefaultValue != null) {