XmlLinkedNode.cs 1.3 KB

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