1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Diagnostics; 6 using System.Xml.XPath; 7 8 namespace System.Xml 9 { 10 // Represents the content of an XML comment. 11 public class XmlComment : XmlCharacterData 12 { XmlComment(string comment, XmlDocument doc)13 protected internal XmlComment(string comment, XmlDocument doc) : base(comment, doc) 14 { 15 } 16 17 // Gets the name of the node. 18 public override String Name 19 { 20 get { return OwnerDocument.strCommentName; } 21 } 22 23 // Gets the name of the current node without the namespace prefix. 24 public override String LocalName 25 { 26 get { return OwnerDocument.strCommentName; } 27 } 28 29 // Gets the type of the current node. 30 public override XmlNodeType NodeType 31 { 32 get { return XmlNodeType.Comment; } 33 } 34 35 // Creates a duplicate of this node. CloneNode(bool deep)36 public override XmlNode CloneNode(bool deep) 37 { 38 Debug.Assert(OwnerDocument != null); 39 return OwnerDocument.CreateComment(Data); 40 } 41 42 // Saves the node to the specified XmlWriter. WriteTo(XmlWriter w)43 public override void WriteTo(XmlWriter w) 44 { 45 w.WriteComment(Data); 46 } 47 48 // Saves all the children of the node to the specified XmlWriter. WriteContentTo(XmlWriter w)49 public override void WriteContentTo(XmlWriter w) 50 { 51 // Intentionally do nothing 52 } 53 54 internal override XPathNodeType XPNodeType { get { return XPathNodeType.Comment; } } 55 } 56 } 57 58