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 = 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, Prefix, NamespaceURI))
            {
                string       name     = ((Prefix.Length > 0) ? "xmlns" + ":" + Prefix : "xmlns");
                XmlAttribute nsattrib = (XmlAttribute)OwnerDocument.CreateAttribute(name);
                nsattrib.Value = NamespaceURI;
                anc.TrackNamespaceNode(nsattrib, nsListToRender, nsLocallyDeclared);
            }

            if (IsInNodeSet)
            {
                anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared);
                rgbData = utf8.GetBytes("<" + 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 = ChildNodes;

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

            anc.ExitElementContext();

            if (IsInNodeSet)
            {
                rgbData = utf8.GetBytes("</" + Name + ">");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
        }
        public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            Hashtable  nsLocallyDeclared = new Hashtable();
            SortedList nsListToRender    = new SortedList(new NamespaceSortOrder());
            SortedList attrListToRender  = new SortedList(new AttributeSortOrder());

            XmlAttributeCollection attrList = 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, Prefix, NamespaceURI))
            {
                string       name     = ((Prefix.Length > 0) ? "xmlns" + ":" + Prefix : "xmlns");
                XmlAttribute nsattrib = (XmlAttribute)OwnerDocument.CreateAttribute(name);
                nsattrib.Value = NamespaceURI;
                anc.TrackNamespaceNode(nsattrib, nsListToRender, nsLocallyDeclared);
            }

            if (IsInNodeSet)
            {
                anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared);

                strBuilder.Append('<').Append(Name);
                foreach (object attr in nsListToRender.GetKeyList())
                {
                    (attr as CanonicalXmlAttribute).Write(strBuilder, docPos, anc);
                }
                foreach (object attr in attrListToRender.GetKeyList())
                {
                    (attr as CanonicalXmlAttribute).Write(strBuilder, docPos, anc);
                }
                strBuilder.Append('>');
            }

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

            XmlNodeList childNodes = ChildNodes;

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

            anc.ExitElementContext();

            if (IsInNodeSet)
            {
                strBuilder.Append("</" + Name + ">");
            }
        }
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     byte[] bytes;
     Hashtable nsLocallyDeclared = new Hashtable();
     SortedList nsListToRender = new SortedList(new NamespaceSortOrder());
     SortedList attrListToRender = new SortedList(new AttributeSortOrder());
     UTF8Encoding encoding = new UTF8Encoding(false);
     XmlAttributeCollection attributes = this.Attributes;
     if (attributes != null)
     {
         foreach (XmlAttribute attribute in attributes)
         {
             if ((((CanonicalXmlAttribute) attribute).IsInNodeSet || System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute)) || System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute))
             {
                 if (System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute))
                 {
                     anc.TrackNamespaceNode(attribute, nsListToRender, nsLocallyDeclared);
                 }
                 else if (System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute))
                 {
                     anc.TrackXmlNamespaceNode(attribute, nsListToRender, attrListToRender, nsLocallyDeclared);
                 }
                 else if (this.IsInNodeSet)
                 {
                     attrListToRender.Add(attribute, null);
                 }
             }
         }
     }
     if (!System.Security.Cryptography.Xml.Utils.IsCommittedNamespace(this, this.Prefix, this.NamespaceURI))
     {
         string name = (this.Prefix.Length > 0) ? ("xmlns:" + this.Prefix) : "xmlns";
         XmlAttribute attr = this.OwnerDocument.CreateAttribute(name);
         attr.Value = this.NamespaceURI;
         anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared);
     }
     if (this.IsInNodeSet)
     {
         anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared);
         bytes = encoding.GetBytes("<" + this.Name);
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         foreach (object obj2 in nsListToRender.GetKeyList())
         {
             (obj2 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
         }
         foreach (object obj3 in attrListToRender.GetKeyList())
         {
             (obj3 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
         }
         bytes = encoding.GetBytes(">");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
     }
     anc.EnterElementContext();
     anc.LoadUnrenderedNamespaces(nsLocallyDeclared);
     anc.LoadRenderedNamespaces(nsListToRender);
     foreach (XmlNode node in this.ChildNodes)
     {
         CanonicalizationDispatcher.WriteHash(node, hash, docPos, anc);
     }
     anc.ExitElementContext();
     if (this.IsInNodeSet)
     {
         bytes = encoding.GetBytes("</" + this.Name + ">");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
     }
 }
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            byte[]                 bytes;
            Hashtable              nsLocallyDeclared = new Hashtable();
            SortedList             nsListToRender    = new SortedList(new NamespaceSortOrder());
            SortedList             attrListToRender  = new SortedList(new AttributeSortOrder());
            UTF8Encoding           encoding          = new UTF8Encoding(false);
            XmlAttributeCollection attributes        = this.Attributes;

            if (attributes != null)
            {
                foreach (XmlAttribute attribute in attributes)
                {
                    if ((((CanonicalXmlAttribute)attribute).IsInNodeSet || System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute)) || System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute))
                    {
                        if (System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute))
                        {
                            anc.TrackNamespaceNode(attribute, nsListToRender, nsLocallyDeclared);
                        }
                        else if (System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute))
                        {
                            anc.TrackXmlNamespaceNode(attribute, nsListToRender, attrListToRender, nsLocallyDeclared);
                        }
                        else if (this.IsInNodeSet)
                        {
                            attrListToRender.Add(attribute, null);
                        }
                    }
                }
            }
            if (!System.Security.Cryptography.Xml.Utils.IsCommittedNamespace(this, this.Prefix, this.NamespaceURI))
            {
                string       name = (this.Prefix.Length > 0) ? ("xmlns:" + this.Prefix) : "xmlns";
                XmlAttribute attr = this.OwnerDocument.CreateAttribute(name);
                attr.Value = this.NamespaceURI;
                anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared);
            }
            if (this.IsInNodeSet)
            {
                anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared);
                bytes = encoding.GetBytes("<" + this.Name);
                hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
                foreach (object obj2 in nsListToRender.GetKeyList())
                {
                    (obj2 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                foreach (object obj3 in attrListToRender.GetKeyList())
                {
                    (obj3 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                bytes = encoding.GetBytes(">");
                hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
            }
            anc.EnterElementContext();
            anc.LoadUnrenderedNamespaces(nsLocallyDeclared);
            anc.LoadRenderedNamespaces(nsListToRender);
            foreach (XmlNode node in this.ChildNodes)
            {
                CanonicalizationDispatcher.WriteHash(node, hash, docPos, anc);
            }
            anc.ExitElementContext();
            if (this.IsInNodeSet)
            {
                bytes = encoding.GetBytes("</" + this.Name + ">");
                hash.TransformBlock(bytes, 0, bytes.Length, bytes, 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);
            }
        }