Esempio n. 1
0
        private void WriteAttribute(XmlDictionaryReader reader, bool defattr)
        {
            if (!defattr && reader.IsDefault)
            {
                return;
            }

            WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
#if NET_2_1
            // no ReadAttributeValue() in 2.1 profile.
            WriteTextNode(reader, true);
#else
            while (reader.ReadAttributeValue())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    WriteTextNode(reader, true);
                    break;

                case XmlNodeType.EntityReference:
                    WriteEntityRef(reader.Name);
                    break;
                }
            }
#endif
            WriteEndAttribute();
        }
 public static XmlAttributeHolder[] ReadAttributes(XmlDictionaryReader reader, ref int maxSizeOfHeaders)
 {
     if (reader.AttributeCount == 0)
         return emptyArray;
     XmlAttributeHolder[] attributes = new XmlAttributeHolder[reader.AttributeCount];
     reader.MoveToFirstAttribute();
     for (int i = 0; i < attributes.Length; i++)
     {
         string ns = reader.NamespaceURI;
         string localName = reader.LocalName;
         string prefix = reader.Prefix;
         string value = string.Empty;
         while (reader.ReadAttributeValue())
         {
             if (value.Length == 0)
                 value = reader.Value;
             else
                 value += reader.Value;
         }
         Deduct(prefix, ref maxSizeOfHeaders);
         Deduct(localName, ref maxSizeOfHeaders);
         Deduct(ns, ref maxSizeOfHeaders);
         Deduct(value, ref maxSizeOfHeaders);
         attributes[i] = new XmlAttributeHolder(prefix, localName, ns, value);
         reader.MoveToNextAttribute();
     }
     reader.MoveToElement();
     return attributes;
 }
Esempio n. 3
0
        private void WriteElementNode(XmlDictionaryReader reader, bool defattr)
        {
            XmlDictionaryString?localName;
            XmlDictionaryString?namespaceUri;

            if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
            {
                WriteStartElement(reader.Prefix, localName, namespaceUri);
            }
            else
            {
                WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
            }
            if (defattr || !reader.IsDefault)
            {
                if (reader.MoveToFirstAttribute())
                {
                    do
                    {
                        if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
                        {
                            WriteStartAttribute(reader.Prefix, localName, namespaceUri);
                        }
                        else
                        {
                            WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                        }
                        while (reader.ReadAttributeValue())
                        {
                            if (reader.NodeType == XmlNodeType.EntityReference)
                            {
                                WriteEntityRef(reader.Name);
                            }
                            else
                            {
                                WriteTextNode(reader, true);
                            }
                        }
                        WriteEndAttribute();
                    }while (reader.MoveToNextAttribute());
                    reader.MoveToElement();
                }
            }
            if (reader.IsEmptyElement)
            {
                WriteEndElement();
            }
        }
Esempio n. 4
0
        private void WriteElementNode(XmlDictionaryReader reader, bool defattr)
        {
            XmlDictionaryString str;
            XmlDictionaryString str2;

            if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
            {
                this.WriteStartElement(reader.Prefix, str, str2);
            }
            else
            {
                this.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
            }
            if ((defattr || (!reader.IsDefault && ((reader.SchemaInfo == null) || !reader.SchemaInfo.IsDefault))) && reader.MoveToFirstAttribute())
            {
                do
                {
                    if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
                    {
                        this.WriteStartAttribute(reader.Prefix, str, str2);
                    }
                    else
                    {
                        this.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    }
                    while (reader.ReadAttributeValue())
                    {
                        if (reader.NodeType == XmlNodeType.EntityReference)
                        {
                            this.WriteEntityRef(reader.Name);
                        }
                        else
                        {
                            this.WriteTextNode(reader, true);
                        }
                    }
                    this.WriteEndAttribute();
                }while (reader.MoveToNextAttribute());
                reader.MoveToElement();
            }
            if (reader.IsEmptyElement)
            {
                this.WriteEndElement();
            }
        }
 private void WriteElementNode(XmlDictionaryReader reader, bool defattr)
 {
     XmlDictionaryString str;
     XmlDictionaryString str2;
     if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
     {
         this.WriteStartElement(reader.Prefix, str, str2);
     }
     else
     {
         this.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
     }
     if ((defattr || (!reader.IsDefault && ((reader.SchemaInfo == null) || !reader.SchemaInfo.IsDefault))) && reader.MoveToFirstAttribute())
     {
         do
         {
             if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
             {
                 this.WriteStartAttribute(reader.Prefix, str, str2);
             }
             else
             {
                 this.WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
             }
             while (reader.ReadAttributeValue())
             {
                 if (reader.NodeType == XmlNodeType.EntityReference)
                 {
                     this.WriteEntityRef(reader.Name);
                 }
                 else
                 {
                     this.WriteTextNode(reader, true);
                 }
             }
             this.WriteEndAttribute();
         }
         while (reader.MoveToNextAttribute());
         reader.MoveToElement();
     }
     if (reader.IsEmptyElement)
     {
         this.WriteEndElement();
     }
 }
Esempio n. 6
0
		private void WriteAttribute (XmlDictionaryReader reader, bool defattr)
		{
			if (!defattr && reader.IsDefault)
				return;

			XmlDictionaryString name, ns;
			if (reader.TryGetLocalNameAsDictionaryString (out name) && reader.TryGetLocalNameAsDictionaryString (out ns))
				WriteStartAttribute (reader.Prefix, name, ns);
			else
				WriteStartAttribute (reader.Prefix, reader.LocalName, reader.NamespaceURI);
#if NET_2_1
			// no ReadAttributeValue() in 2.1 profile.
			WriteTextNode (reader, true);
#else
			while (reader.ReadAttributeValue ()) {
				switch (reader.NodeType) {
				case XmlNodeType.Text:
					WriteTextNode (reader, true);
					break;
				case XmlNodeType.EntityReference:
					WriteEntityRef (reader.Name);
					break;
				}
			}
#endif
			WriteEndAttribute ();
		}
 void WriteElementNode(XmlDictionaryReader reader, bool defattr)
 {
     XmlDictionaryString localName;
     XmlDictionaryString namespaceUri;
     if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
     {
         WriteStartElement(reader.Prefix, localName, namespaceUri);
     }
     else
     {
         WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
     }
     if (defattr || (!reader.IsDefault && (reader.SchemaInfo == null || !reader.SchemaInfo.IsDefault)))
     {
         if (reader.MoveToFirstAttribute())
         {
             do
             {
                 if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
                 {
                     WriteStartAttribute(reader.Prefix, localName, namespaceUri);
                 }
                 else
                 {
                     WriteStartAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                 }
                 while (reader.ReadAttributeValue())
                 {
                     if (reader.NodeType == XmlNodeType.EntityReference)
                     {
                         WriteEntityRef(reader.Name);
                     }
                     else
                     {
                         WriteTextNode(reader, true);
                     }
                 }
                 WriteEndAttribute();
             }
             while (reader.MoveToNextAttribute());
             reader.MoveToElement();
         }
     }
     if (reader.IsEmptyElement)
     {
         WriteEndElement();
     }
 }
 public static XmlAttributeHolder[] ReadAttributes(XmlDictionaryReader reader, ref int maxSizeOfHeaders)
 {
     if (reader.AttributeCount == 0)
     {
         return emptyArray;
     }
     XmlAttributeHolder[] holderArray = new XmlAttributeHolder[reader.AttributeCount];
     reader.MoveToFirstAttribute();
     for (int i = 0; i < holderArray.Length; i++)
     {
         string namespaceURI = reader.NamespaceURI;
         string localName = reader.LocalName;
         string prefix = reader.Prefix;
         string s = string.Empty;
         while (reader.ReadAttributeValue())
         {
             if (s.Length == 0)
             {
                 s = reader.Value;
             }
             else
             {
                 s = s + reader.Value;
             }
         }
         Deduct(prefix, ref maxSizeOfHeaders);
         Deduct(localName, ref maxSizeOfHeaders);
         Deduct(namespaceURI, ref maxSizeOfHeaders);
         Deduct(s, ref maxSizeOfHeaders);
         holderArray[i] = new XmlAttributeHolder(prefix, localName, namespaceURI, s);
         reader.MoveToNextAttribute();
     }
     reader.MoveToElement();
     return holderArray;
 }
Esempio n. 9
0
		public void MoveToElementSimpleDummyRoot ()
		{
			reader = CreateReader ("1234");
			reader.Read (); // element
			Assert.IsTrue (reader.MoveToFirstAttribute (), "#1");
			Assert.IsTrue (reader.MoveToElement (), "#1-1");

			Assert.IsTrue (reader.MoveToFirstAttribute (), "#2");
			Assert.IsTrue (reader.ReadAttributeValue (), "#2-1");
			Assert.IsTrue (reader.MoveToElement (), "#2-2");

			Assert.IsTrue (reader.MoveToFirstAttribute (), "#3");
			Assert.IsFalse (reader.MoveToNextAttribute (), "#3-1");
			Assert.IsTrue (reader.MoveToElement (), "#3-2");
		}
Esempio n. 10
0
		public void MoveToAttributeSimpleDummyRoot ()
		{
			reader = CreateReader ("1234");
			Assert.IsFalse (reader.MoveToFirstAttribute (), "#1");
			reader.Read (); // element
			Assert.IsTrue (reader.MoveToFirstAttribute (), "#2");
			Assert.AreEqual ("type", reader.LocalName, "#3");
			Assert.AreEqual ("number", reader.Value, "#4");
			Assert.IsTrue (reader.ReadAttributeValue (), "#5");
			Assert.AreEqual ("number", reader.Value, "#6");
			Assert.IsFalse (reader.MoveToNextAttribute (), "#7");
			Assert.IsTrue (reader.MoveToFirstAttribute (), "#8");
			Assert.IsFalse (reader.MoveToNextAttribute (), "#9");
		}
Esempio n. 11
0
		public void MoveToAttributeArray ()
		{
			reader = CreateReader ("[]");
			Assert.IsFalse (reader.MoveToFirstAttribute (), "#1");
			reader.Read (); // element
			Assert.IsTrue (reader.MoveToFirstAttribute (), "#2");
			Assert.AreEqual ("type", reader.LocalName, "#3");
			Assert.AreEqual ("array", reader.Value, "#4");
			Assert.IsTrue (reader.ReadAttributeValue (), "#5");
			Assert.AreEqual ("array", reader.Value, "#6");
			Assert.IsFalse (reader.MoveToNextAttribute (), "#7");
			Assert.IsTrue (reader.MoveToFirstAttribute (), "#8");
			Assert.IsFalse (reader.MoveToNextAttribute (), "#9");
		}
Esempio n. 12
0
 public override bool ReadAttributeValue()
 {
     return(reader.ReadAttributeValue());
 }