public XProcessingInstruction(System.Xml.Linq.XProcessingInstruction other) { }
internal static XNode ReadFrom (XmlReader r, LoadOptions options) { switch (r.NodeType) { case XmlNodeType.Element: return XElement.LoadCore (r, options); case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Text: XText t = new XText (r.Value); t.FillLineInfoAndBaseUri (r, options); r.Read (); return t; case XmlNodeType.CDATA: XCData c = new XCData (r.Value); c.FillLineInfoAndBaseUri (r, options); r.Read (); return c; case XmlNodeType.ProcessingInstruction: XPI pi = new XPI (r.Name, r.Value); pi.FillLineInfoAndBaseUri (r, options); r.Read (); return pi; case XmlNodeType.Comment: XComment cm = new XComment (r.Value); cm.FillLineInfoAndBaseUri (r, options); r.Read (); return cm; case XmlNodeType.DocumentType: XDocumentType d = new XDocumentType (r.Name, r.GetAttribute ("PUBLIC"), r.GetAttribute ("SYSTEM"), r.Value); d.FillLineInfoAndBaseUri (r, options); r.Read (); return d; default: throw new InvalidOperationException (String.Format ("Node type {0} is not supported", r.NodeType)); } }
public bool Equals(XNode n1, XNode n2) { if (n1 == null) { return(n2 == null); } else if (n2 == null) { return(false); } //throw new NotImplementedException (); if (n1.NodeType != n2.NodeType) { return(false); } switch (n1.NodeType) { case XmlNodeType.Document: XDocument doc1 = (XDocument)n1; XDocument doc2 = (XDocument)n2; if (!Equals(doc1.Declaration, doc2.Declaration)) { return(false); } IEnumerator <XNode> id2 = doc2.Nodes().GetEnumerator(); foreach (XNode n in doc1.Nodes()) { if (!id2.MoveNext()) { return(false); } if (!Equals(n, id2.Current)) { return(false); } } return(!id2.MoveNext()); case XmlNodeType.Element: XElement e1 = (XElement)n1; XElement e2 = (XElement)n2; if (e1.Name != e2.Name) { return(false); } IEnumerator <XAttribute> ia2 = e2.Attributes().GetEnumerator(); foreach (XAttribute n in e1.Attributes()) { if (!ia2.MoveNext()) { return(false); } if (!Equals(n, ia2.Current)) { return(false); } } if (ia2.MoveNext()) { return(false); } IEnumerator <XNode> ie2 = e2.Nodes().GetEnumerator(); foreach (XNode n in e1.Nodes()) { if (!ie2.MoveNext()) { return(false); } if (!Equals(n, ie2.Current)) { return(false); } } return(!ie2.MoveNext()); case XmlNodeType.Comment: XComment c1 = (XComment)n1; XComment c2 = (XComment)n2; return(c1.Value == c2.Value); case XmlNodeType.ProcessingInstruction: XPI p1 = (XPI)n1; XPI p2 = (XPI)n2; return(p1.Target == p2.Target && p1.Data == p2.Data); case XmlNodeType.DocumentType: XDocumentType d1 = (XDocumentType)n1; XDocumentType d2 = (XDocumentType)n2; return(d1.Name == d2.Name && d1.PublicId == d2.PublicId && d1.SystemId == d2.SystemId && d1.InternalSubset == d2.InternalSubset); case XmlNodeType.Text: return(((XText)n1).Value == ((XText)n2).Value); } throw new Exception("INTERNAL ERROR: should not happen"); }