Merge pull request #554 from deplinenoise/ppc_fixes
[mono.git] / mcs / class / System.Xml.Linq / System.Xml.Linq / XElement.cs
index 924f64ca8272945a411032eb7a6a652af1ac9927..80ba33b662332394e89f44393fbe7ea925b47263 100644 (file)
@@ -52,12 +52,16 @@ namespace System.Xml.Linq
 
                public XElement (XName name, object content)
                {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
                        this.name = name;
                        Add (content);
                }
 
                public XElement (XElement other)
                {
+                       if (other == null)
+                               throw new ArgumentNullException ("other");
                        name = other.name;
                        Add (other.Attributes ());
                        Add (other.Nodes ());
@@ -65,17 +69,23 @@ namespace System.Xml.Linq
 
                public XElement (XName name)
                {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
                        this.name = name;
                }
 
                public XElement (XName name, params object [] content)
                {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
                        this.name = name;
                        Add (content);
                }
 
                public XElement (XStreamingElement other)
                {
+                       if (other == null)
+                               throw new ArgumentNullException ("other");
                        this.name = other.Name;
                        Add (other.Contents);
                }
@@ -330,7 +340,9 @@ namespace System.Xml.Linq
                        set {
                                if (value == null)
                                        throw new ArgumentNullException ("Name");
+                               OnNameChanging (this);
                                name = value;
+                               OnNameChanged (this);
                        }
                }
 
@@ -395,12 +407,7 @@ namespace System.Xml.Linq
 
                static void DefineDefaultSettings (XmlReaderSettings settings, LoadOptions options)
                {
-#if MOONLIGHT
-                       // 2.1 has a DtdProcessing property which defaults to DtdProcessing.Prohibit
-                       settings.DtdProcessing = DtdProcessing.Parse;
-#else
                        settings.ProhibitDtd = false;
-#endif
 
                        settings.IgnoreWhitespace = (options & LoadOptions.PreserveWhitespace) == 0;
                }
@@ -455,7 +462,7 @@ namespace System.Xml.Linq
                        }
                }
 
-#if MOONLIGHT || MOBILE || NET_4_0
+#if NET_4_0
                public static XElement Load (Stream stream)
                {
                        return Load (stream, LoadOptions.None);
@@ -537,7 +544,7 @@ namespace System.Xml.Linq
 
                        if ((options & SaveOptions.DisableFormatting) == SaveOptions.None)
                                s.Indent = true;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0
                        if ((options & SaveOptions.OmitDuplicateNamespaces) == SaveOptions.OmitDuplicateNamespaces)
                                s.NamespaceHandling |= NamespaceHandling.OmitDuplicates;
 #endif
@@ -557,7 +564,7 @@ namespace System.Xml.Linq
                        
                        if ((options & SaveOptions.DisableFormatting) == SaveOptions.None)
                                s.Indent = true;
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0
                        if ((options & SaveOptions.OmitDuplicateNamespaces) == SaveOptions.OmitDuplicateNamespaces)
                                s.NamespaceHandling |= NamespaceHandling.OmitDuplicates;
 #endif
@@ -571,7 +578,7 @@ namespace System.Xml.Linq
                        WriteTo (writer);
                }
 
-#if NET_4_0 || MOONLIGHT || MOBILE
+#if NET_4_0
                public void Save (Stream stream)
                {
                        Save (stream, SaveOptions.None);
@@ -641,6 +648,7 @@ namespace System.Xml.Linq
 
                void SetAttributeObject (XAttribute a)
                {
+                       OnAddingObject (a);
                        a = (XAttribute) XUtil.GetDetachedObject (a);
                        a.SetOwner (this);
                        if (attr_first == null) {
@@ -651,6 +659,7 @@ namespace System.Xml.Linq
                                a.PreviousAttribute = attr_last;
                                attr_last = a;
                        }
+                       OnAddedObject (a);
                }
 
                string LookupPrefix (string ns, XmlWriter w)