* XmlAttribute.cs : add internal 'IsDefault' property
[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
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(ParentNode == null) {
34                                         return null;
35                                 }
36                                 else if (Object.ReferenceEquals(nextSibling, ParentNode.LastLinkedChild.NextLinkedSibling) == false) {
37                                         return nextSibling;
38                                 }
39                                 else {
40                                         return null;
41                                 }
42                         }
43                 }
44
45                 internal XmlLinkedNode NextLinkedSibling
46                 {
47                         get { return nextSibling; }
48                         set { nextSibling = value; }
49                 }
50
51                 public override XmlNode PreviousSibling
52                 {
53                         get {
54                                 if (ParentNode != null) {
55                                         XmlNode node = ParentNode.FirstChild;
56                                         if (node != this) {
57                                                 do {
58                                                         if (node.NextSibling == this)
59                                                                 return node;
60                                                 } while ((node = node.NextSibling) != null);
61                                         }                                       
62                                 }
63                                 return null;
64                         }
65                 }
66
67                 #endregion
68         }
69 }