string documentation;
bool includeInSchema;
bool isNullable = true;
+ bool isAny;
ArrayList _derivedTypes = new ArrayList();
set { isNullable = value; }
}
+ internal bool IsAny
+ {
+ get { return isAny; }
+ set { isAny = value; }
+ }
+
internal XmlTypeMapping GetRealTypeMap (Type objectType)
{
if (TypeData.SchemaType == SchemaTypes.Enum)
internal class XmlSerializableMapping : XmlTypeMapping
{
XmlSchema _schema;
-#if NET_2_0 && !MOONLIGHT
XmlSchemaComplexType _schemaType;
XmlQualifiedName _schemaTypeName;
-#endif
internal XmlSerializableMapping(XmlRootAttribute root, string elementName, string ns, TypeData typeData, string xmlType, string xmlTypeNamespace)
: base(elementName, ns, typeData, xmlType, xmlTypeNamespace)
{
-#if NET_2_0 && !MOONLIGHT
XmlSchemaProviderAttribute schemaProvider = (XmlSchemaProviderAttribute) Attribute.GetCustomAttribute (typeData.Type, typeof (XmlSchemaProviderAttribute));
if (schemaProvider != null) {
+ _schemaTypeName = XmlQualifiedName.Empty;
+
+ if (schemaProvider.IsAny) {
+ IsAny = true;
+ return;
+ }
+
string method = schemaProvider.MethodName;
MethodInfo mi = typeData.Type.GetMethod (method, BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
if (mi == null)
throw new InvalidOperationException (String.Format ("Method '{0}' indicated by XmlSchemaProviderAttribute must have its return type as XmlQualifiedName", method));
XmlSchemaSet xs = new XmlSchemaSet ();
object retVal = mi.Invoke (null, new object [] { xs });
- _schemaTypeName = XmlQualifiedName.Empty;
if (retVal == null)
return;
return;
}
-#endif
-#if NET_2_0 && !MOONLIGHT
+
IXmlSerializable serializable = (IXmlSerializable)Activator.CreateInstance (typeData.Type, true);
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 && !MOONLIGHT
internal XmlSchemaType SchemaType {
get { return _schemaType; }
}
internal XmlQualifiedName SchemaTypeName {
get { return _schemaTypeName; }
}
-#endif
}
return (XmlTypeMapMemberAttribute)_attributeMembers [BuildKey (name,ns, -1)];
}
- public XmlTypeMapElementInfo GetElement (string name, string ns, int order)
+ public XmlTypeMapElementInfo GetElement(string name, string ns, int minimalOrder)
{
if (_elements == null) return null;
- return (XmlTypeMapElementInfo)_elements [BuildKey (name,ns, order)];
+
+ foreach (XmlTypeMapElementInfo info in _elements.Values)
+ if (info.ElementName == name && info.Namespace == ns && info.ExplicitOrder >= minimalOrder)
+ return info;
+
+ return null;
+ }
+
+ public XmlTypeMapElementInfo GetElement(string name, string ns)
+ {
+ if (_elements == null) return null;
+
+ foreach (XmlTypeMapElementInfo info in _elements.Values)
+ if (info.ElementName == name && info.Namespace == ns)
+ return info;
+
+ return null;
}
public XmlTypeMapElementInfo GetElement (int index)