internal void ReadFrom(DiscoveryVersion discoveryVersion, XmlReader reader)
        {
            if (discoveryVersion == null)
            {
                throw FxTrace.Exception.ArgumentNull("discoveryVersion");
            }
            if (reader == null)
            {
                throw FxTrace.Exception.ArgumentNull("reader");
            }

            reader.MoveToContent();
            if (reader.IsEmptyElement)
            {
                reader.Read();
                return;
            }

            int startDepth = reader.Depth;
            reader.ReadStartElement();

            this.endpointAddress = SerializationUtility.ReadEndpointAddress(discoveryVersion, reader);

            this.extensions = null;
            this.duration = TimeSpan.MaxValue;
            while (true)
            {
                reader.MoveToContent();

                if ((reader.NodeType == XmlNodeType.EndElement) && (reader.Depth == startDepth))
                {
                    break;
                }
                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();
                }
            }
        }
Exemplo n.º 2
0
        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();         
        }
 public ServiceDiscoveryBehavior()
 {
     this.announcementEndpoints = new NonNullItemCollection<AnnouncementEndpoint>();
 }