Exemplo n.º 1
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         CanonicalizationDispatcher.WriteGenericNode(this, strBuilder, docPos, anc);
     }
 }
Exemplo n.º 2
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (!IsInNodeSet || !IncludeComments)
            {
                return;
            }

            UTF8Encoding utf8 = new UTF8Encoding(false);

            byte[] rgbData = utf8.GetBytes("(char) 10");
            if (docPos == DocPosition.AfterRootElement)
            {
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
            rgbData = utf8.GetBytes("<!--");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            rgbData = utf8.GetBytes(this.Value);
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            rgbData = utf8.GetBytes("-->");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            if (docPos == DocPosition.BeforeRootElement)
            {
                rgbData = utf8.GetBytes("(char) 10");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
        }
Exemplo n.º 3
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         CanonicalizationDispatcher.WriteHashGenericNode(this, hash, docPos, anc);
     }
 }
Exemplo n.º 4
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         strBuilder.Append(Utils.EscapeCData(this.Data));
     }
 }
Exemplo n.º 5
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet && docPos == DocPosition.InRootElement)
     {
         strBuilder.Append(Utils.EscapeWhitespaceData(this.Value));
     }
 }
Exemplo n.º 6
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (!IsInNodeSet)
            {
                return;
            }

            UTF8Encoding utf8 = new UTF8Encoding(false);

            byte[] rgbData;
            if (docPos == DocPosition.AfterRootElement)
            {
                rgbData = utf8.GetBytes("(char) 10");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
            rgbData = utf8.GetBytes("<?");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            rgbData = utf8.GetBytes((this.Name));
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            if ((this.Value != null) && (this.Value.Length > 0))
            {
                rgbData = utf8.GetBytes(" " + this.Value);
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
            rgbData = utf8.GetBytes("?>");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            if (docPos == DocPosition.BeforeRootElement)
            {
                rgbData = utf8.GetBytes("(char) 10");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
        }
Exemplo n.º 7
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         UTF8Encoding utf8    = new UTF8Encoding(false);
         byte[]       rgbData = utf8.GetBytes(Utils.EscapeCData(this.Data));
         hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
     }
 }
Exemplo n.º 8
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            UTF8Encoding utf8 = new UTF8Encoding(false);

            byte[] rgbData = utf8.GetBytes(" " + this.Name + "=\"");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            rgbData = utf8.GetBytes(Utils.EscapeAttributeValue(this.Value));
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            rgbData = utf8.GetBytes("\"");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
        }
Exemplo n.º 9
0
 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);
         }
     }
 }
Exemplo n.º 10
0
        public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (!IsInNodeSet || !IncludeComments)
            {
                return;
            }

            if (docPos == DocPosition.AfterRootElement)
            {
                strBuilder.Append((char)10);
            }
            strBuilder.Append("<!--");
            strBuilder.Append(this.Value);
            strBuilder.Append("-->");
            if (docPos == DocPosition.BeforeRootElement)
            {
                strBuilder.Append((char)10);
            }
        }
Exemplo n.º 11
0
        public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (!IsInNodeSet)
            {
                return;
            }

            if (docPos == DocPosition.AfterRootElement)
            {
                strBuilder.Append((char)10);
            }
            strBuilder.Append("<?");
            strBuilder.Append(this.Name);
            if ((this.Value != null) && (this.Value.Length > 0))
            {
                strBuilder.Append(" " + this.Value);
            }
            strBuilder.Append("?>");
            if (docPos == DocPosition.BeforeRootElement)
            {
                strBuilder.Append((char)10);
            }
        }
Exemplo n.º 12
0
        public static void WriteHashGenericNode(XmlNode node, HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            XmlNodeList childNodes = node.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                WriteHash(childNode, hash, docPos, anc);
            }
        }
Exemplo n.º 13
0
 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);
     }
 }
Exemplo n.º 14
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     strBuilder.Append(" " + this.Name + "=\"");
     strBuilder.Append(Utils.EscapeAttributeValue(this.Value));
     strBuilder.Append("\"");
 }
Exemplo n.º 15
0
 public static void Write(XmlNode node, StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (node is ICanonicalizableNode)
     {
         ((ICanonicalizableNode)node).Write(strBuilder, docPos, anc);
     }
     else
     {
         WriteGenericNode(node, strBuilder, docPos, anc);
     }
 }
Exemplo n.º 16
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            Hashtable    nsLocallyDeclared = new Hashtable();
            SortedList   nsListToRender    = new SortedList(new NamespaceSortOrder());
            SortedList   attrListToRender  = new SortedList(new AttributeSortOrder());
            UTF8Encoding utf8 = new UTF8Encoding(false);

            byte[] rgbData;

            XmlAttributeCollection attrList = this.Attributes;

            if (attrList != null)
            {
                foreach (XmlAttribute attr in attrList)
                {
                    if (((CanonicalXmlAttribute)attr).IsInNodeSet || Utils.IsNamespaceNode(attr) || Utils.IsXmlNamespaceNode(attr))
                    {
                        if (Utils.IsNamespaceNode(attr))
                        {
                            anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared);
                        }
                        else if (Utils.IsXmlNamespaceNode(attr))
                        {
                            anc.TrackXmlNamespaceNode(attr, nsListToRender, attrListToRender, nsLocallyDeclared);
                        }
                        else if (IsInNodeSet)
                        {
                            attrListToRender.Add(attr, null);
                        }
                    }
                }
            }

            if (!Utils.IsCommittedNamespace(this, this.Prefix, this.NamespaceURI))
            {
                string       name     = ((this.Prefix.Length > 0) ? "xmlns" + ":" + this.Prefix : "xmlns");
                XmlAttribute nsattrib = (XmlAttribute)this.OwnerDocument.CreateAttribute(name);
                nsattrib.Value = this.NamespaceURI;
                anc.TrackNamespaceNode(nsattrib, nsListToRender, nsLocallyDeclared);
            }

            if (IsInNodeSet)
            {
                anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared);
                rgbData = utf8.GetBytes("<" + this.Name);
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
                foreach (object attr in nsListToRender.GetKeyList())
                {
                    (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                foreach (object attr in attrListToRender.GetKeyList())
                {
                    (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                rgbData = utf8.GetBytes(">");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }

            anc.EnterElementContext();
            anc.LoadUnrenderedNamespaces(nsLocallyDeclared);
            anc.LoadRenderedNamespaces(nsListToRender);

            XmlNodeList childNodes = this.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc);
            }

            anc.ExitElementContext();

            if (IsInNodeSet)
            {
                rgbData = utf8.GetBytes("</" + this.Name + ">");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
        }
Exemplo n.º 17
0
        public static void WriteGenericNode(XmlNode node, StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            XmlNodeList childNodes = node.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                Write(childNode, strBuilder, docPos, anc);
            }
        }