* The Depth property was not implemented correctly and the Read method did not
[mono.git] / mcs / class / System.XML / System.Xml / XmlLinkedNode.cs
index 2641eefeccfcd4febce859fb3915367011d0550e..090bedcf6b924e0235ad7635a195c3284cbbc1e3 100644 (file)
@@ -1,3 +1,13 @@
+//
+// System.Xml.XmlLinkedNode
+//
+// Authors:
+//   Jason Diamond <jason@injektilo.org>
+//   Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Jason Diamond, Kral Ferch
+//
+\r
 using System;
 
 namespace System.Xml
@@ -5,33 +15,17 @@ namespace System.Xml
        public abstract class XmlLinkedNode : XmlNode
        {
                #region Fields
-               ///////////////////////////////////////////////////////////////////////
-               //
-               //      Fields
-               //
-               ///////////////////////////////////////////////////////////////////////
 
                XmlLinkedNode nextSibling;
 
                #endregion
 
                #region Constructors
-               ///////////////////////////////////////////////////////////////////////
-               //
-               //      Constructors
-               //
-               ///////////////////////////////////////////////////////////////////////
-
-               protected internal XmlLinkedNode(XmlDocument doc) : base(doc) { }
+               internal XmlLinkedNode(XmlDocument doc) : base(doc) { }
 
                #endregion
 
                #region Properties
-               ///////////////////////////////////////////////////////////////////////
-               //
-               //      Properties
-               //
-               ///////////////////////////////////////////////////////////////////////
 
                public override XmlNode NextSibling
                {
@@ -51,14 +45,22 @@ namespace System.Xml
                        set { nextSibling = value; }
                }
 
-               [MonoTODO]
                public override XmlNode PreviousSibling
                {
                        get {
-                               throw new NotImplementedException ();
+                               if (ParentNode != null) {
+                                       XmlNode node = ParentNode.FirstChild;
+                                       if (node != this) {
+                                               do {
+                                                       if (node.NextSibling == this)
+                                                               return node;
+                                               } while ((node = node.NextSibling) != null);
+                                       }                                       
+                               }
+                               return null;
                        }
                }
 
                #endregion
        }
-}
\ No newline at end of file
+}