Kill MOONLIGHT from System.Xml.
[mono.git] / mcs / class / System.XML / System.Xml.Serialization / XmlReflectionImporter.cs
index 63c87fe7df4cecba306a7d7042e963b475294e2a..53a88a46a41f45d7fbffbb2e78b8a2a1886d5365 100644 (file)
@@ -424,9 +424,7 @@ namespace System.Xml.Serialization {
                                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));
@@ -638,16 +636,7 @@ namespace System.Xml.Serialization {
                        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;
@@ -662,12 +651,8 @@ namespace System.Xml.Serialization {
                        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))
@@ -841,7 +826,6 @@ namespace System.Xml.Serialization {
                                        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[]") ||
@@ -853,7 +837,6 @@ namespace System.Xml.Serialization {
                                        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).
@@ -1077,7 +1060,6 @@ namespace System.Xml.Serialization {
 
                        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)));
@@ -1096,7 +1078,6 @@ namespace System.Xml.Serialization {
                                elem.ExplicitOrder = att.Order;
                                list.Add (elem);
                        }
-#endif
                        return list;
                }
 
@@ -1112,9 +1093,7 @@ namespace System.Xml.Serialization {
                                        }
                                        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));
 
@@ -1172,15 +1151,10 @@ namespace System.Xml.Serialization {
                        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