internal void ReadFrom(DiscoveryVersion discoveryVersion, XmlReader reader) { if (discoveryVersion == null) { throw FxTrace.Exception.ArgumentNull("discoveryVersion"); } if (reader == null) { throw FxTrace.Exception.ArgumentNull("reader"); } this.contractTypeNames = null; this.scopes = null; this.scopeMatchBy = DiscoveryDefaults.ScopeMatchBy; this.extensions = null; this.duration = TimeSpan.MaxValue; this.maxResults = int.MaxValue; reader.MoveToContent(); if (reader.IsEmptyElement) { reader.Read(); return; } int startDepth = reader.Depth; reader.ReadStartElement(); if (reader.IsStartElement(ProtocolStrings.SchemaNames.TypesElement, discoveryVersion.Namespace)) { this.contractTypeNames = new ContractTypeNameCollection(); SerializationUtility.ReadContractTypeNames(this.contractTypeNames, reader); } if (reader.IsStartElement(ProtocolStrings.SchemaNames.ScopesElement, discoveryVersion.Namespace)) { this.scopes = new ScopeCollection(); Uri scopeMatchBy = SerializationUtility.ReadScopes(this.scopes, reader); if (scopeMatchBy != null) { this.scopeMatchBy = discoveryVersion.Implementation.ToVersionIndependentScopeMatchBy(scopeMatchBy); } } while (true) { reader.MoveToContent(); if ((reader.NodeType == XmlNodeType.EndElement) && (reader.Depth == startDepth)) { break; } else if (reader.IsStartElement(ProtocolStrings.SchemaNames.MaxResultsElement, ProtocolStrings.VersionInternal.Namespace)) { this.maxResults = SerializationUtility.ReadMaxResults(reader); } else if (reader.IsStartElement(ProtocolStrings.SchemaNames.DurationElement, ProtocolStrings.VersionInternal.Namespace)) { this.duration = SerializationUtility.ReadDuration(reader); } else if (reader.IsStartElement()) { XElement xElement = XElement.ReadFrom(reader) as XElement; Extensions.Add(xElement); } else { reader.Read(); } } reader.ReadEndElement(); }
internal void ReadFrom(DiscoveryVersion discoveryVersion, XmlReader reader) { ThrowIfOpen(); if (discoveryVersion == null) { throw FxTrace.Exception.ArgumentNull("discoveryVersion"); } if (reader == null) { throw FxTrace.Exception.ArgumentNull("reader"); } this.endpointAddress = new EndpointAddress(EndpointAddress.AnonymousUri); this.contractTypeNames = null; this.scopes = null; this.listenUris = null; this.metadataVersion = 0; this.extensions = null; this.isOpen = false; reader.MoveToContent(); if (reader.IsEmptyElement) { throw FxTrace.Exception.AsError(new XmlException(SR2.DiscoveryXmlEndpointNull)); } int startDepth = reader.Depth; reader.ReadStartElement(); this.endpointAddress = SerializationUtility.ReadEndpointAddress(discoveryVersion, reader); if (reader.IsStartElement(ProtocolStrings.SchemaNames.TypesElement, discoveryVersion.Namespace)) { this.contractTypeNames = new OpenableContractTypeNameCollection(false); SerializationUtility.ReadContractTypeNames(this.contractTypeNames, reader); } if (reader.IsStartElement(ProtocolStrings.SchemaNames.ScopesElement, discoveryVersion.Namespace)) { this.scopes = new OpenableScopeCollection(false); SerializationUtility.ReadScopes(this.scopes, reader); } if (reader.IsStartElement(ProtocolStrings.SchemaNames.XAddrsElement, discoveryVersion.Namespace)) { this.listenUris = new OpenableCollection <Uri>(false); SerializationUtility.ReadListenUris(listenUris, reader); } if (reader.IsStartElement(ProtocolStrings.SchemaNames.MetadataVersionElement, discoveryVersion.Namespace)) { this.metadataVersion = SerializationUtility.ReadMetadataVersion(reader); } while (true) { reader.MoveToContent(); if ((reader.NodeType == XmlNodeType.EndElement) && (reader.Depth == startDepth)) { break; } else if (reader.IsStartElement()) { this.Extensions.Add(XElement.ReadFrom(reader) as XElement); } else { reader.Read(); } } reader.ReadEndElement(); }