2002-10-26 Piers Haken <piersh@friskit.com>
[mono.git] / mcs / class / System.XML / System.Xml / XmlLinkedNode.cs
1 //
2 // System.Xml.XmlLinkedNode
3 //
4 // Authors:
5 //   Jason Diamond <jason@injektilo.org>
6 //   Kral Ferch <kral_ferch@hotmail.com>
7 //
8 // (C) 2002 Jason Diamond, Kral Ferch
9 //
10 \r
11 using System;
12
13 namespace System.Xml
14 {
15         public abstract class XmlLinkedNode : XmlNode
16         {
17                 #region Fields
18
19                 XmlLinkedNode nextSibling;
20
21                 #endregion
22
23                 #region Constructors
24                 internal XmlLinkedNode(XmlDocument doc) : base(doc) { }
25
26                 #endregion
27
28                 #region Properties
29
30                 public override XmlNode NextSibling
31                 {
32                         get {
33                                 if (Object.ReferenceEquals(nextSibling, ParentNode.LastLinkedChild.NextLinkedSibling) == false) {
34                                         return nextSibling;
35                                 }
36                                 else {
37                                         return null;
38                                 }
39                         }
40                 }
41
42                 internal XmlLinkedNode NextLinkedSibling
43                 {
44                         get { return nextSibling; }
45                         set { nextSibling = value; }
46                 }
47
48                 public override XmlNode PreviousSibling
49                 {
50                         get {
51                                 if (ParentNode != null) {
52                                         XmlNode node = ParentNode.FirstChild;
53                                         if (node != this) {
54                                                 do {
55                                                         if (node.NextSibling == this)
56                                                                 return node;
57                                                 } while ((node = node.NextSibling) != null);
58                                         }                                       
59                                 }
60                                 return null;
61                         }
62                 }
63
64                 #endregion
65         }
66 }