2002-12-21 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
[mono.git] / mcs / class / System.XML / System.Xml / XmlLinkedNode.cs
index f577d694c707817d1220dfaf2d3e26ecd3b709f2..cc6be542fd446b6cd69324dfa922a9fbb33b7789 100644 (file)
@@ -1,33 +1,77 @@
+//
+// System.Xml.XmlLinkedNode
+//
+// Authors:
+//   Jason Diamond <jason@injektilo.org>
+//   Kral Ferch <kral_ferch@hotmail.com>
+//
+// (C) 2002 Jason Diamond, Kral Ferch
+//
+
 using System;
 
 namespace System.Xml
 {
        public abstract class XmlLinkedNode : XmlNode
        {
-               #region Constructors
+               #region Fields
+
+               XmlLinkedNode nextSibling;
+               XmlLinkedNode lastLinkedChild;
 
-               protected internal XmlLinkedNode(XmlDocument doc) : base(doc) { }
+               #endregion
+
+               #region Constructors
+               internal XmlLinkedNode(XmlDocument doc) : base(doc) { }
 
                #endregion
 
                #region Properties
 
-               [MonoTODO]
                public override XmlNode NextSibling
                {
                        get {
-                               throw new NotImplementedException ();
+                               if(ParentNode == null) {
+                                       return null;
+                               }
+                               else if (Object.ReferenceEquals(nextSibling, ParentNode.LastLinkedChild.NextLinkedSibling) == false) {
+                                       return nextSibling;
+                               }
+                               else {
+                                       return null;
+                               }
                        }
                }
 
-               [MonoTODO]
+               internal XmlLinkedNode NextLinkedSibling
+               {
+                       get { return nextSibling; }
+                       set { nextSibling = value; }
+               }
+
                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;
                        }
                }
 
+               // copied this way from XmlElement
+               internal override XmlLinkedNode LastLinkedChild
+               {
+                       get { return lastLinkedChild; }
+                       set { lastLinkedChild = value; }
+               }
+
                #endregion
        }
-}
\ No newline at end of file
+}