WriteNode() public method

public WriteNode ( System reader, bool defattr ) : void
reader System
defattr bool
return void
		protected override void OnWriteBodyContents (
			XmlDictionaryWriter writer)
		{
			if (reader == null && String.IsNullOrEmpty (xml))
				return;
			XmlReader r = reader ?? XmlReader.Create (new StringReader (xml));
			r.MoveToContent ();
			writer.WriteNode (r, false);
		}
Exemplo n.º 2
0
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     using (XmlReader reader = new XmlTextReader(this.FileName))
     {
         while (!reader.EOF)
         {
             writer.WriteNode(reader, false);
         }
     }
 }
 protected override void OnWriteAddressHeaderContents(XmlDictionaryWriter writer)
 {
     XmlDictionaryReader addressHeaderReader = this.GetAddressHeaderReader();
     addressHeaderReader.ReadStartElement();
     while (addressHeaderReader.NodeType != XmlNodeType.EndElement)
     {
         writer.WriteNode(addressHeaderReader, false);
     }
     addressHeaderReader.ReadEndElement();
     addressHeaderReader.Close();
 }
 protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     XmlDictionaryReader headerReader = this.GetHeaderReader();
     headerReader.ReadStartElement();
     while (headerReader.NodeType != XmlNodeType.EndElement)
     {
         writer.WriteNode(headerReader, false);
     }
     headerReader.ReadEndElement();
     headerReader.Close();
 }
Exemplo n.º 5
0
        /// <summary>
        /// When overridden in a non-abstract derived class, writes the contents of the detail element. 
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Xml.XmlDictionaryWriter"/> used to write the detail element.</param>
        protected override void OnWriteDetailContents(XmlDictionaryWriter writer)
        {
            var prefix = writer.LookupPrefix(this._nameSpace) ?? "web";
            using (var reader = this._messageFault.GetReaderAtDetailContents())
            {
                if ("Error".Equals(reader.LocalName) && string.IsNullOrWhiteSpace(reader.NamespaceURI))
                {
                    writer.WriteStartElement(prefix, "Error", this._nameSpace);
                    reader.Read();

                    // ErrorMessage
                    writer.WriteNode(reader, false);

                    // ErrorNumber
                    writer.WriteNode(reader, false);

                    // 
                    writer.WriteNode(reader, false);
                }
            }
        }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     using (this.reader)
     {
         for (XmlNodeType type = this.reader.MoveToContent(); !this.reader.EOF && (type != XmlNodeType.EndElement); type = this.reader.MoveToContent())
         {
             if (type != XmlNodeType.Element)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("InvalidReaderPositionOnCreateMessage"), "reader"));
             }
             writer.WriteNode(this.reader, false);
         }
     }
 }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     if (!this.isEmpty)
     {
         using (XmlDictionaryReader reader = this.OnGetReaderAtBodyContents())
         {
             if ((reader.ReadState != System.Xml.ReadState.Error) && (reader.ReadState != System.Xml.ReadState.Closed))
             {
                 goto Label_005E;
             }
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageBodyReaderInvalidReadState", new object[] { reader.ReadState.ToString() })));
         Label_0056:
             writer.WriteNode(reader, false);
         Label_005E:
             if ((reader.NodeType != XmlNodeType.EndElement) && !reader.EOF)
             {
                 goto Label_0056;
             }
             base.ReadFromBodyContentsToEnd(reader);
         }
     }
 }
Exemplo n.º 8
0
 protected override void OnBodyToString(XmlDictionaryWriter writer)
 {
     using (XmlDictionaryReader reader = GetBufferedReaderAtBody())
     {
         while (reader.NodeType != XmlNodeType.EndElement)
         {
             writer.WriteNode(reader, false);
         }
     }
 }
Exemplo n.º 9
0
 public static void WriteNodeToWriter(byte[] buffer, XmlDictionaryWriter writer)
 {
     using (XmlDictionaryReader reader = Utility.CreateReader(buffer))
     {
         writer.WriteNode((XmlReader)reader, false);
     }
 }
Exemplo n.º 10
0
 protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     XmlDictionaryReader reader = GetHeaderReader();
     reader.ReadStartElement();
     while (reader.NodeType != XmlNodeType.EndElement)
         writer.WriteNode(reader, false);
     reader.ReadEndElement();
     reader.Dispose();
 }
Exemplo n.º 11
0
 public override void WriteObjectContent(XmlDictionaryWriter writer, object graph)
 {
     if (writer == null) throw new ArgumentNullException("writer");
     if (writer.WriteState != WriteState.Element)
         throw new SerializationException(string.Format("WriteState '{0}' not valid. Caller must write start element before serializing in contentOnly mode.",
             writer.WriteState));
     using (MemoryStream memoryStream = new MemoryStream())
     {
         using (XmlDictionaryWriter bufferWriter = XmlDictionaryWriter.CreateTextWriter(memoryStream, Encoding.UTF8))
         {
             serializer.Serialize(bufferWriter, graph);
             bufferWriter.Flush();
             memoryStream.Position = 0;
             using (XmlReader reader = new XmlTextReader(memoryStream))
             {
                 reader.MoveToContent();
                 writer.WriteAttributes(reader, false);
                 if (reader.Read()) // move off start node (we want to skip it)
                 {
                     while (reader.NodeType != XmlNodeType.EndElement) // also skip end node.
                         writer.WriteNode(reader, false); // this will take us to the start of the next child node, or the end node.
                     reader.ReadEndElement(); // not necessary, but clean
                 }
             }
         }
     }
 }
 private void WriteContentsTo200408(XmlDictionaryWriter writer)
 {
     writer.WriteStartElement(XD.AddressingDictionary.Address, XD.Addressing200408Dictionary.Namespace);
     if (this.isAnonymous)
     {
         writer.WriteString(XD.Addressing200408Dictionary.Anonymous);
     }
     else
     {
         if (this.isNone)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("addressingVersion", System.ServiceModel.SR.GetString("SFxNone2004"));
         }
         writer.WriteString(this.Uri.AbsoluteUri);
     }
     writer.WriteEndElement();
     if ((this.headers != null) && this.headers.HasReferenceProperties)
     {
         writer.WriteStartElement(XD.AddressingDictionary.ReferenceProperties, XD.Addressing200408Dictionary.Namespace);
         this.headers.WriteReferencePropertyContentsTo(writer);
         writer.WriteEndElement();
     }
     if ((this.headers != null) && this.headers.HasNonReferenceProperties)
     {
         writer.WriteStartElement(XD.AddressingDictionary.ReferenceParameters, XD.Addressing200408Dictionary.Namespace);
         this.headers.WriteNonReferencePropertyContentsTo(writer);
         writer.WriteEndElement();
     }
     XmlDictionaryReader readerAtSection = null;
     if (this.pspSection >= 0)
     {
         readerAtSection = GetReaderAtSection(this.buffer, this.pspSection);
         Copy(writer, readerAtSection);
     }
     readerAtSection = null;
     if (this.metadataSection >= 0)
     {
         readerAtSection = GetReaderAtSection(this.buffer, this.metadataSection);
         Copy(writer, readerAtSection);
     }
     if (this.Identity != null)
     {
         this.Identity.WriteTo(writer);
     }
     if (this.extensionSection >= 0)
     {
         readerAtSection = GetReaderAtSection(this.buffer, this.extensionSection);
         while (readerAtSection.IsStartElement())
         {
             if (readerAtSection.NamespaceURI == AddressingVersion.WSAddressingAugust2004.Namespace)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(readerAtSection, System.ServiceModel.SR.GetString("AddressingExtensionInBadNS", new object[] { readerAtSection.LocalName, readerAtSection.NamespaceURI })));
             }
             writer.WriteNode(readerAtSection, true);
         }
     }
 }
 protected override void OnBodyToString(XmlDictionaryWriter writer)
 {
     using (XmlDictionaryReader reader = this.GetBufferedReaderAtBody())
     {
         if (this.Version == MessageVersion.None)
         {
             writer.WriteNode(reader, false);
         }
         else if (!reader.IsEmptyElement)
         {
             reader.ReadStartElement();
             while (reader.NodeType != XmlNodeType.EndElement)
             {
                 writer.WriteNode(reader, false);
             }
         }
     }
 }
Exemplo n.º 14
0
 public override void WriteNode(XmlReader reader, bool defattr)
 {
     writer.WriteNode(reader, defattr);
 }
 private string GetSignatureHash(MessageHeader header, string headerId, IPrefixGenerator prefixGenerator, XmlDictionaryWriter writer, out byte[] hash)
 {
     XmlDictionaryWriter writer2;
     HashStream stream = this.TakeHashStream();
     XmlBuffer buffer = null;
     if (writer.CanCanonicalize)
     {
         writer2 = writer;
     }
     else
     {
         buffer = new XmlBuffer(0x7fffffff);
         writer2 = buffer.OpenSection(XmlDictionaryReaderQuotas.Max);
     }
     writer2.StartCanonicalization(stream, false, null);
     header.WriteStartHeader(writer2, base.Version);
     if (headerId == null)
     {
         headerId = base.GenerateId();
         base.StandardsManager.IdManager.WriteIdAttribute(writer2, headerId);
     }
     header.WriteHeaderContents(writer2, base.Version);
     writer2.WriteEndElement();
     writer2.EndCanonicalization();
     writer2.Flush();
     if (!object.ReferenceEquals(writer2, writer))
     {
         buffer.CloseSection();
         buffer.Close();
         XmlDictionaryReader reader = buffer.GetReader(0);
         writer.WriteNode(reader, false);
         reader.Close();
     }
     hash = stream.FlushHashAndGetValue();
     return headerId;
 }
Exemplo n.º 16
0
		protected override void OnWriteBodyContents (
			XmlDictionaryWriter writer)
		{
			if (consumed)
				throw new InvalidOperationException ("Body xml reader is already consumed");
			if (reader == null && String.IsNullOrEmpty (xml_bak))
				return;
			XmlReader r = xml_bak != null ? XmlReader.Create (new StringReader (xml_bak), null, parser_context) : reader;
			r.MoveToContent ();
			writer.WriteNode (r, false);
			if (xml_bak == null)
				consumed = true;
		}
Exemplo n.º 17
0
			protected override void OnWriteHeaderContents (
				XmlDictionaryWriter writer, MessageVersion version)
			{
				var r = CreateReader ();
				r.MoveToContent ();
				if (r.IsEmptyElement)
					return; // write nothing
				for (r.Read (); r.NodeType != XmlNodeType.EndElement;)
					writer.WriteNode (r, false);
			}
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            if (!IsEmpty)
            {
                if (!isInboundRequest)
                {
                    writer.WriteStartElement(IsXmlRpcMethodCall ? XmlRpcProtocol.MethodCall : XmlRpcProtocol.MethodResponse);

                    if (IsXmlRpcMethodCall)
                    {
                        writer.WriteStartElement(XmlRpcProtocol.MethodName);
                        writer.WriteString((string)properties["XmlRpcMethodName"]);
                        writer.WriteEndElement();
                    }
                }
                writer.WriteNode(bodyReader, true);
                
                if (!isInboundRequest)
                {
                    writer.WriteEndElement();
                }
                
                writer.Flush();
            }
        }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     switch (this.state)
     {
         case BodyState.Created:
             this.InnerMessage.WriteBodyContents(writer);
             return;
         case BodyState.Signed:
         case BodyState.EncryptedThenSigned:
             XmlDictionaryReader reader = fullBodyBuffer.GetReader(0);
             reader.ReadStartElement();
             while (reader.NodeType != XmlNodeType.EndElement)
                 writer.WriteNode(reader, false);
             reader.ReadEndElement();
             reader.Close();
             return;
         case BodyState.Encrypted:
         case BodyState.SignedThenEncrypted:
             this.encryptedBodyContent.WriteTo(writer, ServiceModelDictionaryManager.Instance);
             break;
         default:
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateBadStateException("OnWriteBodyContents"));
     }
 }
 public override void WriteTokenCore(XmlDictionaryWriter writer, SecurityToken token)
 {
     BufferedGenericXmlSecurityToken token2 = token as BufferedGenericXmlSecurityToken;
     if ((token2 != null) && (token2.TokenXmlBuffer != null))
     {
         using (XmlDictionaryReader reader = token2.TokenXmlBuffer.GetReader(0))
         {
             writer.WriteNode(reader, false);
             return;
         }
     }
     GenericXmlSecurityToken token3 = (GenericXmlSecurityToken) token;
     token3.TokenXml.WriteTo(writer);
 }
 public override void WriteTokenCore(XmlDictionaryWriter writer, SecurityToken token)
 {
     BufferedGenericXmlSecurityToken bufferedXmlToken = token as BufferedGenericXmlSecurityToken;
     if (bufferedXmlToken != null && bufferedXmlToken.TokenXmlBuffer != null)
     {
         using (XmlDictionaryReader reader = bufferedXmlToken.TokenXmlBuffer.GetReader(0))
         {
             writer.WriteNode(reader, false);
         }
     }
     else
     {
         GenericXmlSecurityToken xmlToken = (GenericXmlSecurityToken)token;
         xmlToken.TokenXml.WriteTo(writer);
     }
 }
Exemplo n.º 22
0
        void WriteContentsTo200408(XmlDictionaryWriter writer)
        {
            // Address
            writer.WriteStartElement(XD.AddressingDictionary.Address, XD.Addressing200408Dictionary.Namespace);
            if (isAnonymous)
            {
                writer.WriteString(XD.Addressing200408Dictionary.Anonymous);
            }
            else if (isNone)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("addressingVersion", SR.GetString(SR.SFxNone2004));
            }
            else
            {
                writer.WriteString(this.Uri.AbsoluteUri);
            }
            writer.WriteEndElement();

            // ReferenceProperties
            if (this.headers != null && this.headers.HasReferenceProperties)
            {
                writer.WriteStartElement(XD.AddressingDictionary.ReferenceProperties, XD.Addressing200408Dictionary.Namespace);
                this.headers.WriteReferencePropertyContentsTo(writer);
                writer.WriteEndElement();
            }

            // ReferenceParameters
            if (this.headers != null && this.headers.HasNonReferenceProperties)
            {
                writer.WriteStartElement(XD.AddressingDictionary.ReferenceParameters, XD.Addressing200408Dictionary.Namespace);
                this.headers.WriteNonReferencePropertyContentsTo(writer);
                writer.WriteEndElement();
            }

            // PSP (PortType, ServiceName, Policy)
            XmlDictionaryReader reader = null;
            if (pspSection >= 0)
            {
                reader = GetReaderAtSection(buffer, pspSection);
                Copy(writer, reader);
            }

            // Metadata
            reader = null;
            if (metadataSection >= 0)
            {
                reader = GetReaderAtSection(buffer, metadataSection);
                Copy(writer, reader);
            }

            // EndpointIdentity
            if (this.Identity != null)
            {
                this.Identity.WriteTo(writer);
            }

            // Extensions
            if (this.extensionSection >= 0)
            {
                reader = GetReaderAtSection(this.buffer, extensionSection);
                while (reader.IsStartElement())
                {
                    if (reader.NamespaceURI == AddressingVersion.WSAddressingAugust2004.Namespace)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, SR.GetString(SR.AddressingExtensionInBadNS, reader.LocalName, reader.NamespaceURI)));
                    }

                    writer.WriteNode(reader, true);
                }
            }
        }
Exemplo n.º 23
0
        public void AddReference(string headerId, XmlDictionaryReader reader, XmlDictionaryWriter writer)
        {
            HashStream hashStream = this.TakeHashStream();
            writer.StartCanonicalization(hashStream, false, this.InclusivePrefixes);

            // The reader must be positioned on the start element of the header / body we want to canonicalize
            writer.WriteNode(reader, false);
            writer.EndCanonicalization();
            writer.Flush();

            // Add a reference for this block
            this.AddReference(headerId, hashStream.FlushHashAndGetValue());
        }
            protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
            {
                XmlDictionaryReader reader = this.originalMessage.GetReaderAtBodyContents();

                // Write root StartElement
                writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                writer.WriteAttributes(reader, true);
                reader.ReadStartElement();

                // Write QueryResult StartElement
                writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                writer.WriteAttributes(reader, true);

                // Write QueryResult content
                string nodeName = reader.LocalName;
                reader.Read();

                while (reader.NodeType != XmlNodeType.EndElement || reader.Name != nodeName)
                {
                    XmlReader subtree = reader.ReadSubtree();
                    writer.WriteNode(subtree, false);
                    reader.ReadEndElement();
                }

                // Insert metadata start
                writer.WriteStartElement("Metadata");
                writer.WriteAttributeString("type", "array");
                // This two foreach loops are to ensure we write the return entity of the query first, then all the rest.
                // This is a requirement of the RIA/JS client side implementation. If modifying this, client side needs update too.
                foreach (ServiceMetadataGenerator.TypeMetadata map in ServiceMetadataGenerator.EntitiesMetadata)
                {
                    if (map.Name == this.entityTypeName)
                    {
                        writer.WriteStartElement("item");
                        writer.WriteAttributeString("type", "object");
                        map.WriteJson(writer);
                        writer.WriteEndElement();
                        break;
                    }
                }
                foreach (ServiceMetadataGenerator.TypeMetadata map in ServiceMetadataGenerator.EntitiesMetadata)
                {
                    if (map.Name != this.entityTypeName)
                    {
                        writer.WriteStartElement("item");
                        writer.WriteAttributeString("type", "object");
                        map.WriteJson(writer);
                        writer.WriteEndElement();
                    }
                }
                writer.WriteEndElement();
                // Insert metadata end

                // Close QueryResult
                writer.WriteEndElement();
                // Close root
                writer.WriteEndElement();
            }
Exemplo n.º 25
0
        void WriteContentsTo10(XmlDictionaryWriter writer)
        {
            // Address
            writer.WriteStartElement(XD.AddressingDictionary.Address, XD.Addressing10Dictionary.Namespace);
            if (isAnonymous)
            {
                writer.WriteString(XD.Addressing10Dictionary.Anonymous);
            }
            else if (isNone)
            {
                writer.WriteString(XD.Addressing10Dictionary.NoneAddress);
            }
            else
            {
                writer.WriteString(this.Uri.AbsoluteUri);
            }
            writer.WriteEndElement();

            // Headers
            if (this.headers != null && this.headers.Count > 0)
            {
                writer.WriteStartElement(XD.AddressingDictionary.ReferenceParameters, XD.Addressing10Dictionary.Namespace);
                this.headers.WriteContentsTo(writer);
                writer.WriteEndElement();
            }

            // Metadata
            if (this.metadataSection >= 0)
            {
                XmlDictionaryReader reader = GetReaderAtSection(this.buffer, metadataSection);
                writer.WriteStartElement(XD.Addressing10Dictionary.Metadata, XD.Addressing10Dictionary.Namespace);
                Copy(writer, reader);
                writer.WriteEndElement();
            }

            // EndpointIdentity
            if (this.Identity != null)
            {
                this.Identity.WriteTo(writer);
            }

            // Extensions
            if (this.extensionSection >= 0)
            {
                XmlDictionaryReader reader = GetReaderAtSection(this.buffer, this.extensionSection);
                while (reader.IsStartElement())
                {
                    if (reader.NamespaceURI == AddressingVersion.WSAddressing10.Namespace)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, SR.GetString(SR.AddressingExtensionInBadNS, reader.LocalName, reader.NamespaceURI)));
                    }

                    writer.WriteNode(reader, true);
                }
            }
        }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     XmlDictionaryReader reader = this.buffer.GetReader(0);
     using (reader)
     {
         reader.ReadStartElement();
         while (reader.NodeType != XmlNodeType.EndElement)
         {
             writer.WriteNode(reader, false);
         }
         reader.ReadEndElement();
     }
 }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     writer.WriteNode(JsonReaderWriterFactory.CreateJsonReader(_jsonStream, XmlDictionaryReaderQuotas.Max), false);
     writer.Flush();
 }
        string GetSignatureHash(MessageHeader header, string headerId, IPrefixGenerator prefixGenerator, XmlDictionaryWriter writer, out byte[] hash)
        {
            HashStream hashStream = TakeHashStream();
            XmlDictionaryWriter effectiveWriter;
            XmlBuffer canonicalBuffer = null;

            if (writer.CanCanonicalize)
            {
                effectiveWriter = writer;
            }
            else
            {
                canonicalBuffer = new XmlBuffer(int.MaxValue);
                effectiveWriter = canonicalBuffer.OpenSection(XmlDictionaryReaderQuotas.Max);
            }

            effectiveWriter.StartCanonicalization(hashStream, false, null);

            header.WriteStartHeader(effectiveWriter, this.Version);
            if (headerId == null)
            {
                headerId = GenerateId();
                this.StandardsManager.IdManager.WriteIdAttribute(effectiveWriter, headerId);
            }
            header.WriteHeaderContents(effectiveWriter, this.Version);
            effectiveWriter.WriteEndElement();
            effectiveWriter.EndCanonicalization();
            effectiveWriter.Flush();

            if (!ReferenceEquals(effectiveWriter, writer))
            {
                Fx.Assert(canonicalBuffer != null, "Canonical buffer cannot be null.");
                canonicalBuffer.CloseSection();
                canonicalBuffer.Close();
                XmlDictionaryReader dicReader = canonicalBuffer.GetReader(0);
                writer.WriteNode(dicReader, false);
                dicReader.Close();
            }

            hash = hashStream.FlushHashAndGetValue();

            return headerId;
        }
 internal static void Copy(XmlDictionaryWriter writer, XmlDictionaryReader reader)
 {
     while (!Done(reader))
     {
         writer.WriteNode(reader, true);
     }
 }
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            if (this.state == BodyState.Created)
            {
                this.InnerMessage.WriteBodyContents(writer);
                return;
            }

            XmlDictionaryReader reader = CreateFullBodyReader();
            reader.ReadStartElement();
            while (reader.NodeType != XmlNodeType.EndElement)
                writer.WriteNode(reader, false);
            reader.ReadEndElement();
            reader.Close();
        }
 private void WriteContentsTo10(XmlDictionaryWriter writer)
 {
     writer.WriteStartElement(XD.AddressingDictionary.Address, XD.Addressing10Dictionary.Namespace);
     if (this.isAnonymous)
     {
         writer.WriteString(XD.Addressing10Dictionary.Anonymous);
     }
     else if (this.isNone)
     {
         writer.WriteString(XD.Addressing10Dictionary.NoneAddress);
     }
     else
     {
         writer.WriteString(this.Uri.AbsoluteUri);
     }
     writer.WriteEndElement();
     if ((this.headers != null) && (this.headers.Count > 0))
     {
         writer.WriteStartElement(XD.AddressingDictionary.ReferenceParameters, XD.Addressing10Dictionary.Namespace);
         this.headers.WriteContentsTo(writer);
         writer.WriteEndElement();
     }
     if (this.metadataSection >= 0)
     {
         XmlDictionaryReader readerAtSection = GetReaderAtSection(this.buffer, this.metadataSection);
         writer.WriteStartElement(XD.Addressing10Dictionary.Metadata, XD.Addressing10Dictionary.Namespace);
         Copy(writer, readerAtSection);
         writer.WriteEndElement();
     }
     if (this.Identity != null)
     {
         this.Identity.WriteTo(writer);
     }
     if (this.extensionSection >= 0)
     {
         XmlDictionaryReader reader = GetReaderAtSection(this.buffer, this.extensionSection);
         while (reader.IsStartElement())
         {
             if (reader.NamespaceURI == AddressingVersion.WSAddressing10.Namespace)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, System.ServiceModel.SR.GetString("AddressingExtensionInBadNS", new object[] { reader.LocalName, reader.NamespaceURI })));
             }
             writer.WriteNode(reader, true);
         }
     }
 }