public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         CanonicalizationDispatcher.WriteHashGenericNode(this, hash, docPos, anc);
     }
 }
コード例 #2
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet && (docPos == DocPosition.InRootElement))
     {
         strBuilder.Append(System.Security.Cryptography.Xml.Utils.EscapeWhitespaceData(this.Value));
     }
 }
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         CanonicalizationDispatcher.WriteGenericNode(this, strBuilder, docPos, anc);
     }
 }
コード例 #4
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         strBuilder.Append(Utils.EscapeTextData(Value));
     }
 }
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         byte[] bytes;
         UTF8Encoding encoding = new UTF8Encoding(false);
         if (docPos == DocPosition.AfterRootElement)
         {
             bytes = encoding.GetBytes("(char) 10");
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
         bytes = encoding.GetBytes("<?");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         bytes = encoding.GetBytes(this.Name);
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         if ((this.Value != null) && (this.Value.Length > 0))
         {
             bytes = encoding.GetBytes(" " + this.Value);
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
         bytes = encoding.GetBytes("?>");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         if (docPos == DocPosition.BeforeRootElement)
         {
             bytes = encoding.GetBytes("(char) 10");
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
     }
 }
コード例 #6
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);
     }
 }
コード例 #7
0
ファイル: C14NUtil.cs プロジェクト: dox0/DotNet471RS3
        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);
            }
        }
コード例 #8
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         strBuilder.Append(System.Security.Cryptography.Xml.Utils.EscapeCData(this.Data));
     }
 }
コード例 #9
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet && docPos == DocPosition.InRootElement)
     {
         strBuilder.Append(Utils.EscapeWhitespaceData(Value));
     }
 }
コード例 #10
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);
     }
 }
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         strBuilder.Append(System.Security.Cryptography.Xml.Utils.EscapeTextData(this.Value));
     }
 }
コード例 #12
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         CanonicalizationDispatcher.WriteGenericNode(this, strBuilder, docPos, anc);
     }
 }
コード例 #13
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         CanonicalizationDispatcher.WriteHashGenericNode(this, hash, docPos, anc);
     }
 }
コード例 #14
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((Name));
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            if ((Value != null) && (Value.Length > 0))
            {
                rgbData = utf8.GetBytes(" " + 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);
            }
        }
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         byte[]       bytes;
         UTF8Encoding encoding = new UTF8Encoding(false);
         if (docPos == DocPosition.AfterRootElement)
         {
             bytes = encoding.GetBytes("(char) 10");
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
         bytes = encoding.GetBytes("<?");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         bytes = encoding.GetBytes(this.Name);
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         if ((this.Value != null) && (this.Value.Length > 0))
         {
             bytes = encoding.GetBytes(" " + this.Value);
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
         bytes = encoding.GetBytes("?>");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         if (docPos == DocPosition.BeforeRootElement)
         {
             bytes = encoding.GetBytes("(char) 10");
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
     }
 }
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         byte[] bytes = new UTF8Encoding(false).GetBytes(System.Security.Cryptography.Xml.Utils.EscapeTextData(this.Value));
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
     }
 }
コード例 #17
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         byte[] bytes = new UTF8Encoding(false).GetBytes(System.Security.Cryptography.Xml.Utils.EscapeCData(this.Data));
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
     }
 }
コード例 #18
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);
            }
        }
コード例 #19
0
ファイル: CanonicalXmlText.cs プロジェクト: PKRoma/corefx
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         UTF8Encoding utf8 = new UTF8Encoding(false);
         byte[] rgbData = utf8.GetBytes(Utils.EscapeTextData(Value));
         hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
     }
 }
コード例 #20
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
     {
         UTF8Encoding utf8    = new UTF8Encoding(false);
         byte[]       rgbData = utf8.GetBytes(Utils.EscapeTextData(Value));
         hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
     }
 }
コード例 #21
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);
            }
        }
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     UTF8Encoding encoding = new UTF8Encoding(false);
     byte[] bytes = encoding.GetBytes(" " + this.Name + "=\"");
     hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
     bytes = encoding.GetBytes(System.Security.Cryptography.Xml.Utils.EscapeAttributeValue(this.Value));
     hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
     bytes = encoding.GetBytes("\"");
     hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
 }
コード例 #23
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            UTF8Encoding encoding = new UTF8Encoding(false);

            byte[] bytes = encoding.GetBytes(" " + this.Name + "=\"");
            hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
            bytes = encoding.GetBytes(System.Security.Cryptography.Xml.Utils.EscapeAttributeValue(this.Value));
            hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
            bytes = encoding.GetBytes("\"");
            hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
        }
コード例 #24
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            UTF8Encoding utf8 = new UTF8Encoding(false);

            byte[] rgbData = utf8.GetBytes(" " + Name + "=\"");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            rgbData = utf8.GetBytes(Utils.EscapeAttributeValue(Value));
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            rgbData = utf8.GetBytes("\"");
            hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
        }
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     docPos = DocPosition.BeforeRootElement;
     foreach (XmlNode node in this.ChildNodes)
     {
         if (node.NodeType == XmlNodeType.Element)
         {
             CanonicalizationDispatcher.Write(node, strBuilder, DocPosition.InRootElement, anc);
             docPos = DocPosition.AfterRootElement;
         }
         else
         {
             CanonicalizationDispatcher.Write(node, strBuilder, docPos, anc);
         }
     }
 }
コード例 #26
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     docPos = DocPosition.BeforeRootElement;
     foreach (XmlNode childNode in ChildNodes)
     {
         if (childNode.NodeType == XmlNodeType.Element)
         {
             CanonicalizationDispatcher.WriteHash(childNode, hash, DocPosition.InRootElement, anc);
             docPos = DocPosition.AfterRootElement;
         }
         else
         {
             CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc);
         }
     }
 }
コード例 #27
0
ファイル: C14NUtil.cs プロジェクト: dox0/DotNet471RS3
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     docPos = DocPosition.BeforeRootElement;
     foreach (XmlNode childNode in this.ChildNodes)
     {
         if (childNode.NodeType == XmlNodeType.Element)
         {
             CanonicalizationDispatcher.Write(childNode, strBuilder, DocPosition.InRootElement, anc);
             docPos = DocPosition.AfterRootElement;
         }
         else
         {
             CanonicalizationDispatcher.Write(childNode, strBuilder, docPos, anc);
         }
     }
 }
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet && this.IncludeComments)
     {
         if (docPos == DocPosition.AfterRootElement)
         {
             strBuilder.Append('\n');
         }
         strBuilder.Append("<!--");
         strBuilder.Append(this.Value);
         strBuilder.Append("-->");
         if (docPos == DocPosition.BeforeRootElement)
         {
             strBuilder.Append('\n');
         }
     }
 }
コード例 #29
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet && this.IncludeComments)
     {
         if (docPos == DocPosition.AfterRootElement)
         {
             strBuilder.Append('\n');
         }
         strBuilder.Append("<!--");
         strBuilder.Append(this.Value);
         strBuilder.Append("-->");
         if (docPos == DocPosition.BeforeRootElement)
         {
             strBuilder.Append('\n');
         }
     }
 }
コード例 #30
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(Value);
            strBuilder.Append("-->");
            if (docPos == DocPosition.BeforeRootElement)
            {
                strBuilder.Append((char)10);
            }
        }
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         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)
         {
             strBuilder.Append('\n');
         }
     }
 }
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet)
     {
         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)
         {
             strBuilder.Append('\n');
         }
     }
 }
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet && this.IncludeComments)
     {
         UTF8Encoding encoding = new UTF8Encoding(false);
         byte[] bytes = encoding.GetBytes("(char) 10");
         if (docPos == DocPosition.AfterRootElement)
         {
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
         bytes = encoding.GetBytes("<!--");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         bytes = encoding.GetBytes(this.Value);
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         bytes = encoding.GetBytes("-->");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         if (docPos == DocPosition.BeforeRootElement)
         {
             bytes = encoding.GetBytes("(char) 10");
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
     }
 }
コード例 #34
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(Name);
            if ((Value != null) && (Value.Length > 0))
            {
                strBuilder.Append(" " + Value);
            }
            strBuilder.Append("?>");
            if (docPos == DocPosition.BeforeRootElement)
            {
                strBuilder.Append((char)10);
            }
        }
コード例 #35
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (this.IsInNodeSet && this.IncludeComments)
     {
         UTF8Encoding encoding = new UTF8Encoding(false);
         byte[]       bytes    = encoding.GetBytes("(char) 10");
         if (docPos == DocPosition.AfterRootElement)
         {
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
         bytes = encoding.GetBytes("<!--");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         bytes = encoding.GetBytes(this.Value);
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         bytes = encoding.GetBytes("-->");
         hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         if (docPos == DocPosition.BeforeRootElement)
         {
             bytes = encoding.GetBytes("(char) 10");
             hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
         }
     }
 }
コード例 #36
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     strBuilder.Append($" {Name}=\"");
     strBuilder.Append(Utils.EscapeAttributeValue(Value));
     strBuilder.Append('"');
 }
コード例 #37
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 = 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);
            }
        }
コード例 #38
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 Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     strBuilder.Append(" " + this.Name + "=\"");
     strBuilder.Append(System.Security.Cryptography.Xml.Utils.EscapeAttributeValue(this.Value));
     strBuilder.Append("\"");
 }
コード例 #41
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc) {
     if (IsInNodeSet && docPos == DocPosition.InRootElement)
         strBuilder.Append(Utils.EscapeWhitespaceData(this.Value));
 }
コード例 #42
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);
            }
        }
コード例 #43
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);
            }
        }
コード例 #44
0
 public static void WriteHashGenericNode(XmlNode node, HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     foreach (XmlNode node2 in node.ChildNodes)
     {
         WriteHash(node2, hash, docPos, anc);
     }
 }
コード例 #45
0
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     strBuilder.Append(" " + this.Name + "=\"");
     strBuilder.Append(System.Security.Cryptography.Xml.Utils.EscapeAttributeValue(this.Value));
     strBuilder.Append("\"");
 }
コード例 #46
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);
            }
        }
コード例 #47
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);
     }
 }
コード例 #48
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);
        }
コード例 #49
0
        public static void WriteGenericNode(XmlNode node, StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            XmlNodeList childNodes = node.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                Write(childNode, strBuilder, docPos, anc);
            }
        }
コード例 #50
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);
 }
コード例 #51
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);
     }
 }
コード例 #52
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);
            }
        }
コード例 #53
0
        public static void WriteHashGenericNode(XmlNode node, HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            XmlNodeList childNodes = node.ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                WriteHash(childNode, hash, docPos, anc);
            }
        }
コード例 #54
0
ファイル: CanonicalXmlText.cs プロジェクト: PKRoma/corefx
 public void Write(StringBuilder strBuilder, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     if (IsInNodeSet)
         strBuilder.Append(Utils.EscapeTextData(Value));
 }
コード例 #55
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);
         }
     }
 }