internal void WriteTo(DiscoveryVersion discoveryVersion, XmlWriter writer)
        {
            if (discoveryVersion == null)
            {
                throw FxTrace.Exception.ArgumentNull("discoveryVersion");
            }
            if (writer == null)
            {
                throw FxTrace.Exception.ArgumentNull("writer");
            }

            SerializationUtility.WriteEndPointAddress(discoveryVersion, this.endpointAddress, writer);

            SerializationUtility.WriteContractTypeNames(discoveryVersion, this.contractTypeNames, writer);


            SerializationUtility.WriteScopes(discoveryVersion, this.scopes, null, writer);

            SerializationUtility.WriteListenUris(discoveryVersion, this.listenUris, writer);

            SerializationUtility.WriteMetadataVersion(discoveryVersion, this.metadataVersion, writer);

            if (this.extensions != null)
            {
                foreach (XElement xElement in Extensions)
                {
                    xElement.WriteTo(writer);
                }
            }
        }
        internal void WriteTo(DiscoveryVersion discoveryVersion, XmlWriter writer)
        {
            if (discoveryVersion == null)
            {
                throw FxTrace.Exception.ArgumentNull("discoveryVersion");
            }
            if (writer == null)
            {
                throw FxTrace.Exception.ArgumentNull("writer");
            }

            SerializationUtility.WriteContractTypeNames(discoveryVersion, this.contractTypeNames, writer);

            SerializationUtility.WriteScopes(discoveryVersion, this.scopes, this.scopeMatchBy, writer);

            if (this.maxResults != int.MaxValue)
            {
                writer.WriteElementString(
                    ProtocolStrings.SchemaNames.MaxResultsElement,
                    ProtocolStrings.VersionInternal.Namespace,
                    this.maxResults.ToString(CultureInfo.InvariantCulture));
            }
            if (this.duration != TimeSpan.MaxValue)
            {
                writer.WriteElementString(
                    ProtocolStrings.SchemaNames.DurationElement,
                    ProtocolStrings.VersionInternal.Namespace,
                    XmlConvert.ToString(this.Duration));
            }

            if (this.extensions != null)
            {
                foreach (XElement xElement in Extensions)
                {
                    xElement.WriteTo(writer);
                }
            }
        }