public void WriteHash( HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet || !this.IncludeComments) { return; } UTF8Encoding utF8Encoding = new UTF8Encoding(false); byte[] bytes1 = utF8Encoding.GetBytes("(char) 10"); if (docPos == DocPosition.AfterRootElement) { hash.TransformBlock(bytes1, 0, bytes1.Length, bytes1, 0); } byte[] bytes2 = utF8Encoding.GetBytes("<!--"); hash.TransformBlock(bytes2, 0, bytes2.Length, bytes2, 0); byte[] bytes3 = utF8Encoding.GetBytes(this.Value); hash.TransformBlock(bytes3, 0, bytes3.Length, bytes3, 0); byte[] bytes4 = utF8Encoding.GetBytes("-->"); hash.TransformBlock(bytes4, 0, bytes4.Length, bytes4, 0); if (docPos != DocPosition.BeforeRootElement) { return; } byte[] bytes5 = utF8Encoding.GetBytes("(char) 10"); hash.TransformBlock(bytes5, 0, bytes5.Length, bytes5, 0); }
public void Write( StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet) { return; } if (docPos == DocPosition.AfterRootElement) { strBuilder.Append('\n'); } strBuilder.Append("<?"); strBuilder.Append(this.Name); if (this.Value != null && this.Value.Length > 0) { strBuilder.Append(" " + this.Value); } strBuilder.Append("?>"); if (docPos != DocPosition.BeforeRootElement) { return; } strBuilder.Append('\n'); }
public void Write( [NotNull] StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { strBuilder.Append(" " + Name + "=\""); strBuilder.Append(Exml.EscapeAttributeValue(Value)); strBuilder.Append("\""); }
public void Write( StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet || docPos != DocPosition.InRootElement) { return; } strBuilder.Append(Exml.EscapeWhitespaceData(this.Value)); }
public void Write( StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet) { return; } strBuilder.Append(Exml.EscapeTextData(this.Data)); }
public void WriteHash( HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet) { return; } CanonicalizationDispatcher.WriteHashGenericNode((XmlNode)this, hash, docPos, anc); }
public void Write( StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet) { return; } CanonicalizationDispatcher.WriteGenericNode((XmlNode)this, strBuilder, docPos, anc); }
public void WriteHash( HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet || docPos != DocPosition.InRootElement) { return; } byte[] bytes = new UTF8Encoding(false).GetBytes(Exml.EscapeWhitespaceData(this.Value)); hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0); }
public void WriteHash( [NotNull] HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { UTF8Encoding utF8Encoding = new UTF8Encoding(false); byte[] bytes1 = utF8Encoding.GetBytes(" " + Name + "=\""); hash.TransformBlock(bytes1, 0, bytes1.Length, bytes1, 0); byte[] bytes2 = utF8Encoding.GetBytes(Exml.EscapeAttributeValue(Value)); hash.TransformBlock(bytes2, 0, bytes2.Length, bytes2, 0); byte[] bytes3 = utF8Encoding.GetBytes("\""); hash.TransformBlock(bytes3, 0, bytes3.Length, bytes3, 0); }
public static void WriteHashGenericNode( XmlNode node, HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { if (node == null) { throw new ArgumentNullException(nameof(node)); } foreach (XmlNode childNode in node.ChildNodes) { WriteHash(childNode, hash, docPos, anc); } }
public static void WriteHash( XmlNode node, HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { if (node is ICanonicalizableNode) { ((ICanonicalizableNode)node).WriteHash(hash, docPos, anc); } else { WriteHashGenericNode(node, hash, docPos, anc); } }
public static void WriteGenericNode( XmlNode node, StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { if (node == null) { throw new ArgumentNullException(nameof(node)); } foreach (XmlNode childNode in node.ChildNodes) { Write(childNode, strBuilder, docPos, anc); } }
public static void Write( XmlNode node, StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { if (node is ICanonicalizableNode canonicalizableNode) { canonicalizableNode.Write(strBuilder, docPos, anc); } else { WriteGenericNode(node, strBuilder, docPos, anc); } }
public void WriteHash( HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { docPos = DocPosition.BeforeRootElement; foreach (XmlNode childNode in this.ChildNodes) { if (childNode.NodeType == XmlNodeType.Element) { CanonicalizationDispatcher.WriteHash(childNode, hash, DocPosition.InRootElement, anc); docPos = DocPosition.AfterRootElement; } else { CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc); } } }
public void Write( StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) { if (!this.IsInNodeSet || !this.IncludeComments) { return; } if (docPos == DocPosition.AfterRootElement) { strBuilder.Append('\n'); } strBuilder.Append("<!--"); strBuilder.Append(this.Value); strBuilder.Append("-->"); if (docPos != DocPosition.BeforeRootElement) { return; } strBuilder.Append('\n'); }
public void WriteHash( HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { Hashtable nsLocallyDeclared = new Hashtable(); SortedList sortedList = new SortedList((IComparer) new NamespaceSortOrder()); SortedList attrListToRender = new SortedList((IComparer) new AttributeSortOrder()); UTF8Encoding utF8Encoding = new UTF8Encoding(false); XmlAttributeCollection attributes = this.Attributes; if (attributes != null) { foreach (XmlAttribute attr in (XmlNamedNodeMap)attributes) { if (((CanonicalXmlAttribute)attr).IsInNodeSet || Exml.IsNamespaceNode((XmlNode)attr) || Exml.IsXmlNamespaceNode((XmlNode)attr)) { if (Exml.IsNamespaceNode((XmlNode)attr)) { anc.TrackNamespaceNode(attr, sortedList, nsLocallyDeclared); } else if (Exml.IsXmlNamespaceNode((XmlNode)attr)) { anc.TrackXmlNamespaceNode(attr, sortedList, attrListToRender, nsLocallyDeclared); } else if (this.IsInNodeSet) { attrListToRender.Add((object)attr, (object)null); } } } } if (!CanonicalXmlNodeList.IsCommittedNamespace((XmlElement)this, this.Prefix, this.NamespaceURI)) { XmlAttribute attribute = this.OwnerDocument.CreateAttribute(this.Prefix.Length > 0 ? "xmlns:" + this.Prefix : "xmlns"); attribute.Value = this.NamespaceURI; anc.TrackNamespaceNode(attribute, sortedList, nsLocallyDeclared); } if (this.IsInNodeSet) { anc.GetNamespacesToRender((XmlElement)this, attrListToRender, sortedList, nsLocallyDeclared); byte[] bytes1 = utF8Encoding.GetBytes("<" + this.Name); hash.TransformBlock(bytes1, 0, bytes1.Length, bytes1, 0); foreach (object key in (IEnumerable)sortedList.GetKeyList()) { (key as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } foreach (object key in (IEnumerable)attrListToRender.GetKeyList()) { (key as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } byte[] bytes2 = utF8Encoding.GetBytes(">"); hash.TransformBlock(bytes2, 0, bytes2.Length, bytes2, 0); } anc.EnterElementContext(); anc.LoadUnrenderedNamespaces(nsLocallyDeclared); anc.LoadRenderedNamespaces(sortedList); foreach (XmlNode childNode in this.ChildNodes) { CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc); } anc.ExitElementContext(); if (!this.IsInNodeSet) { return; } byte[] bytes = utF8Encoding.GetBytes("</" + this.Name + ">"); hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0); }