The Labs \ Source Viewer \ SSCLI \ System.Xml \ XmlLinkedNode

  1. //------------------------------------------------------------------------------
  2. // <copyright file="XmlLinkedNode.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Xml
  16. {
  17.    
  18.     // Gets the node immediately preceeding or following this node.
  19.     public abstract class XmlLinkedNode : XmlNode
  20.     {
  21.         internal XmlLinkedNode next;
  22.        
  23.         internal XmlLinkedNode() : base()
  24.         {
  25.             next = null;
  26.         }
  27.         internal XmlLinkedNode(XmlDocument doc) : base(doc)
  28.         {
  29.             next = null;
  30.         }
  31.        
  32.         // Gets the node immediately preceding this node.
  33.         public override XmlNode PreviousSibling {
  34.             get {
  35.                 XmlNode parent = ParentNode;
  36.                 if (parent != null) {
  37.                     XmlNode node = parent.FirstChild;
  38.                     while (node != null) {
  39.                         XmlNode nextSibling = node.NextSibling;
  40.                         if (nextSibling == this) {
  41.                             break;
  42.                         }
  43.                         node = nextSibling;
  44.                     }
  45.                     return node;
  46.                 }
  47.                 return null;
  48.             }
  49.         }
  50.        
  51.         // Gets the node immediately following this node.
  52.         public override XmlNode NextSibling {
  53.             get {
  54.                 XmlNode parent = ParentNode;
  55.                 if (parent != null) {
  56.                     if (next != parent.FirstChild)
  57.                         return next;
  58.                 }
  59.                 return null;
  60.             }
  61.         }
  62.     }
  63. }

Developer Fusion