XmlTypeMapMember mem = classMap.XmlTextCollector;
if (mem.TypeData.Type != typeof(string) &&
mem.TypeData.Type != typeof(string[]) &&
-#if !MOONLIGHT
mem.TypeData.Type != typeof(XmlNode[]) &&
-#endif
mem.TypeData.Type != typeof(object[]))
throw new InvalidOperationException (String.Format (errSimple2, map.TypeData.TypeName, mem.Name, mem.TypeData.TypeName));
helper.RegisterClrType (map, type, map.XmlTypeNamespace);
return map;
}
-#if MOONLIGHT
- // Enum.GetNames is not available in SL API
- public static System.Collections.Generic.IEnumerable<string> GetEnumNames (Type type)
- {
- System.Collections.Generic.List<string> names = new System.Collections.Generic.List<string> ();
- foreach (FieldInfo fi in type.GetFields (BindingFlags.Static | BindingFlags.Public))
- names.Add (fi.Name);
- return names;
- }
-#endif
+
XmlTypeMapping ImportEnumMapping (TypeData typeData, XmlRootAttribute root, string defaultNamespace)
{
Type type = typeData.Type;
helper.RegisterClrType (map, type, map.XmlTypeNamespace);
ArrayList members = new ArrayList();
-#if MOONLIGHT
- foreach (string name in GetEnumNames (type)) {
-#else
string [] names = Enum.GetNames (type);
foreach (string name in names) {
-#endif
FieldInfo field = type.GetField (name);
string xmlName = null;
if (field.IsDefined(typeof(XmlIgnoreAttribute), false))
throw new InvalidOperationException ("XmlArrayAttribute can be applied to members of array or collection type.");
}
-#if !MOONLIGHT
if (atts.XmlAnyAttribute != null)
{
if ( (rmember.MemberType.FullName == "System.Xml.XmlAttribute[]") ||
throw new InvalidOperationException ("XmlAnyAttributeAttribute can only be applied to members of type XmlAttribute[] or XmlNode[]");
}
else
-#endif
if (atts.XmlAnyElements != null && atts.XmlAnyElements.Count > 0)
{
// no XmlNode type check is done here (seealso: bug #553032).
ImportTextElementInfo (list, rmember.MemberType, member, atts, defaultNamespace);
-#if !MOONLIGHT // no practical anyElement support
foreach (XmlAnyElementAttribute att in atts.XmlAnyElements)
{
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(typeof(XmlElement)));
elem.ExplicitOrder = att.Order;
list.Add (elem);
}
-#endif
return list;
}
}
defaultType = atts.XmlText.Type;
}
-#if !MOONLIGHT
if (defaultType == typeof(XmlNode)) defaultType = typeof(XmlText); // Nodes must be text nodes
-#endif
XmlTypeMapElementInfo elem = new XmlTypeMapElementInfo (member, TypeTranslator.GetTypeData(defaultType, atts.XmlText.DataType));
if (defaultValue == DBNull.Value || typeData.SchemaType != SchemaTypes.Enum)
return defaultValue;
-#if MOONLIGHT
- string namedValue = (defaultValue as Enum).ToString ("g");
- string decimalValue = (defaultValue as Enum).ToString ("d");
-#else
// get string representation of enum value
string namedValue = Enum.Format (typeData.Type, defaultValue, "g");
// get decimal representation of enum value
string decimalValue = Enum.Format (typeData.Type, defaultValue, "d");
-#endif
// if decimal representation matches string representation, then
// the value is not defined in the enum type (as the "g" format
// will return the decimal equivalent of the value if the value