TryGetLocalNameAsDictionaryString() public méthode

public TryGetLocalNameAsDictionaryString ( System &localName ) : bool
localName System
Résultat bool
        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();
            }
        }
Exemple #2
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 WriteArrayNode(XmlDictionaryReader reader, Type type)
        {
            XmlDictionaryString?localName;
            XmlDictionaryString?namespaceUri;

            if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
            {
                WriteArrayNode(reader, reader.Prefix, localName, namespaceUri, type);
            }
            else
            {
                WriteArrayNode(reader, reader.Prefix, reader.LocalName, reader.NamespaceURI, type);
            }
        }
Exemple #4
0
        private void WriteArrayNode(XmlDictionaryReader reader, Type type)
        {
            XmlDictionaryString str;
            XmlDictionaryString str2;

            if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
            {
                this.WriteArrayNode(reader, reader.Prefix, str, str2, type);
            }
            else
            {
                this.WriteArrayNode(reader, reader.Prefix, reader.LocalName, reader.NamespaceURI, type);
            }
        }
Exemple #5
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();
        }
Exemple #6
0
        public virtual void WriteNode(XmlDictionaryReader reader,
                                      bool defattr)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
                // gratuitously copied from System.XML/System.Xml/XmlWriter.cs:WriteNode(XmlReader,bool)
                // as there doesn't seem to be a way to hook into attribute writing w/o handling Element.
                XmlDictionaryString ename, ens;
                if (reader.TryGetLocalNameAsDictionaryString(out ename) && reader.TryGetLocalNameAsDictionaryString(out ens))
                {
                    WriteStartElement(reader.Prefix, ename, ens);
                }
                else
                {
                    WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                }
                // Well, I found that MS.NET took this way, since
                // there was a error-prone SgmlReader that fails
                // MoveToNextAttribute().
                if (reader.HasAttributes)
                {
                    for (int i = 0; i < reader.AttributeCount; i++)
                    {
                        reader.MoveToAttribute(i);
                        WriteAttribute(reader, defattr);
                    }
                    reader.MoveToElement();
                }
                if (reader.IsEmptyElement)
                {
                    WriteEndElement();
                }
                else
                {
                    int depth = reader.Depth;
                    reader.Read();
                    if (reader.NodeType != XmlNodeType.EndElement)
                    {
                        do
                        {
                            WriteNode(reader, defattr);
                        } while (depth < reader.Depth);
                    }
                    WriteFullEndElement();
                }
                reader.Read();
                break;

            case XmlNodeType.Attribute:
            case XmlNodeType.Text:
                WriteTextNode(reader, defattr);
                break;

            default:
                base.WriteNode(reader, defattr);
                break;
            }
        }
 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 WriteArrayNode(XmlDictionaryReader reader, Type type)
 {
     XmlDictionaryString str;
     XmlDictionaryString str2;
     if (reader.TryGetLocalNameAsDictionaryString(out str) && reader.TryGetNamespaceUriAsDictionaryString(out str2))
     {
         this.WriteArrayNode(reader, reader.Prefix, str, str2, type);
     }
     else
     {
         this.WriteArrayNode(reader, reader.Prefix, reader.LocalName, reader.NamespaceURI, type);
     }
 }
Exemple #9
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 ();
		}
Exemple #10
0
		public virtual void WriteNode (XmlDictionaryReader reader,
			bool defattr)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			switch (reader.NodeType) {
			case XmlNodeType.Element:
				// gratuitously copied from System.XML/System.Xml/XmlWriter.cs:WriteNode(XmlReader,bool)
				// as there doesn't seem to be a way to hook into attribute writing w/o handling Element.
				XmlDictionaryString ename, ens;
				if (reader.TryGetLocalNameAsDictionaryString (out ename) && reader.TryGetLocalNameAsDictionaryString (out ens))
					WriteStartElement (reader.Prefix, ename, ens);
				else
					WriteStartElement (reader.Prefix, reader.LocalName, reader.NamespaceURI);
				// Well, I found that MS.NET took this way, since
				// there was a error-prone SgmlReader that fails
				// MoveToNextAttribute().
				if (reader.HasAttributes) {
					for (int i = 0; i < reader.AttributeCount; i++) {
						reader.MoveToAttribute (i);
						WriteAttribute (reader, defattr);
					}
					reader.MoveToElement ();
				}
				if (reader.IsEmptyElement)
					WriteEndElement ();
				else {
					int depth = reader.Depth;
					reader.Read ();
					if (reader.NodeType != XmlNodeType.EndElement) {
						do {
							WriteNode (reader, defattr);
						} while (depth < reader.Depth);
					}
					WriteFullEndElement ();
				}
				reader.Read ();
				break;
			case XmlNodeType.Attribute:
			case XmlNodeType.Text:
				WriteTextNode (reader, defattr);
				break;
			default:
				base.WriteNode (reader, defattr);
				break;
			}
		}
 void WriteArrayNode(XmlDictionaryReader reader, Type type)
 {
     XmlDictionaryString localName;
     XmlDictionaryString namespaceUri;
     if (reader.TryGetLocalNameAsDictionaryString(out localName) && reader.TryGetNamespaceUriAsDictionaryString(out namespaceUri))
         WriteArrayNode(reader, reader.Prefix, localName, namespaceUri, type);
     else
         WriteArrayNode(reader, reader.Prefix, reader.LocalName, reader.NamespaceURI, type);
 }
 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();
     }
 }