Пример #1
0
		internal static ResolveCriteria ReadXml (XmlReader reader, DiscoveryVersion version)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			var ret = new ResolveCriteria ();

			reader.MoveToContent ();
			if (!reader.IsStartElement ("ResolveType", version.Namespace) || reader.IsEmptyElement)
				throw new XmlException ("Non-empty ResolveType element is expected");
			reader.ReadStartElement ("ResolveType", version.Namespace);

			// standard members
			reader.MoveToContent ();
			ret.Address = EndpointAddress.ReadFrom (version.MessageVersion.Addressing, reader);

			// non-standard members
			for (reader.MoveToContent (); !reader.EOF && reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
				if (reader.NamespaceURI == SerializationNS) {
					switch (reader.LocalName) {
					case "Duration":
						ret.Duration = (TimeSpan) reader.ReadElementContentAs (typeof (TimeSpan), null);
						break;
					}
				}
				else
					ret.Extensions.Add (XElement.Load (reader));
			}

			reader.ReadEndElement ();

			return ret;
		}
Пример #2
0
		public AnnouncementEndpoint (DiscoveryVersion discoveryVersion)
			: this (discoveryVersion, null, null)
		{
			if (discoveryVersion == null)
				throw new ArgumentNullException ("discoveryVersion");
			DiscoveryVersion = discoveryVersion;
		}
Пример #3
0
		public AnnouncementEndpoint (DiscoveryVersion discoveryVersion, Binding binding, EndpointAddress address)
			: base (null, binding, address)
		{
			if (discoveryVersion == null)
				throw new ArgumentNullException ("discoveryVersion");
			DiscoveryVersion = discoveryVersion;
		}
Пример #4
0
		static DiscoveryVersion ()
		{
			v11 = new DiscoveryVersion ("WSDiscovery11",
				Namespace11,
				"urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01",
				MessageVersion.Soap12WSAddressing10,
				typeof (Version11.IAnnouncementContract11),
				typeof (AnnouncementClient11),
				typeof (IDiscoveryProxyContract11),
				typeof (DiscoveryProxyClient11),
				typeof (IDiscoveryTargetContract11),
				typeof (DiscoveryTargetClient11));

			april2005 = new DiscoveryVersion ("WSDiscoveryApril2005",
				NamespaceApril2005,
				"urn:schemas-xmlsoap-org:ws:2005:04:discovery",
				MessageVersion.Soap12WSAddressingAugust2004,
				typeof (IAnnouncementContractApril2005),
				typeof (AnnouncementClientApril2005),
				typeof (IDiscoveryProxyContractApril2005),
				typeof (DiscoveryProxyClientApril2005),
				typeof (IDiscoveryTargetContractApril2005),
				typeof (DiscoveryTargetClientApril2005));

			cd1 = new DiscoveryVersion ("WSDiscoveryCD1",
				NamespaceCD1,
				"urn:docs-oasis-open-org:ws-dd:discovery:2008:09",
				MessageVersion.Soap12WSAddressingAugust2004,
				typeof (IAnnouncementContractCD1),
				typeof (AnnouncementClientCD1),
				typeof (IDiscoveryProxyContractCD1),
				typeof (DiscoveryProxyClientCD1),
				typeof (IDiscoveryTargetContractCD1),
				typeof (DiscoveryTargetClientCD1));
		}
Пример #5
0
		public DiscoveryEndpoint (DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode, Binding binding, EndpointAddress endpointAddress)
			: base (GetContract (discoveryVersion, discoveryMode), binding, endpointAddress)
		{
			DiscoveryVersion = discoveryVersion;
			DiscoveryMode = discoveryMode;

			IsSystemEndpoint = true;
		}
Пример #6
0
		// (6), everything falls to here
		public UdpAnnouncementEndpoint (DiscoveryVersion discoveryVersion, Uri multicastAddress)
			: base (discoveryVersion, CreateBinding (), new EndpointAddress (discoveryVersion.AdhocAddress))
		{
			ListenUri = multicastAddress;
			TransportSettings = new UdpTransportSettings ();
			MulticastAddress = multicastAddress;
			MaxAnnouncementDelay = TimeSpan.FromMilliseconds (500);
		}
Пример #7
0
		public DiscoveryEndpoint (DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode, Binding binding, EndpointAddress endpointAddress)
			: base (null, binding, endpointAddress)
		{
			if (discoveryVersion == null)
				throw new ArgumentNullException ("discoveryVersion");
			DiscoveryVersion = discoveryVersion;
			DiscoveryMode = discoveryMode;
		}
Пример #8
0
		// (6), everything falls to here.
		public UdpDiscoveryEndpoint (DiscoveryVersion discoveryVersion, Uri multicastAddress)
			: base (discoveryVersion, ServiceDiscoveryMode.Adhoc, CreateBinding (), new EndpointAddress (discoveryVersion.AdhocAddress))
		{
			ListenUri = multicastAddress;
			TransportSettings = new UdpTransportSettings ();
			MulticastAddress = multicastAddress;
			MaxResponseDelay = TimeSpan.FromMilliseconds (500);
		}
        static ContractDescription GetDiscoveryContract(DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode)
        {
            if (discoveryVersion == null)
            {
                throw FxTrace.Exception.ArgumentNull("discoveryVersion");
            }

            return discoveryVersion.Implementation.GetDiscoveryContract(discoveryMode);
        }
        static ContractDescription GetAnnouncementContract(DiscoveryVersion discoveryVersion)
        {
            if (discoveryVersion == null)
            {
                throw FxTrace.Exception.ArgumentNull("discoveryVersion");
            }

            return discoveryVersion.Implementation.GetAnnouncementContract();
        }
Пример #11
0
        public static XmlQualifiedName EnsureProbeMatchSchema(DiscoveryVersion discoveryVersion, XmlSchemaSet schemaSet)
        {
            Fx.Assert(schemaSet != null, "The schemaSet must be non null.");
            Fx.Assert(discoveryVersion != null, "The discoveryVersion must be non null.");

            // ensure that EPR is added to the schema.
            if (discoveryVersion == DiscoveryVersion.WSDiscoveryApril2005 || discoveryVersion == DiscoveryVersion.WSDiscoveryCD1)
            {
                EndpointAddressAugust2004.GetSchema(schemaSet);
            }
            else if (discoveryVersion == DiscoveryVersion.WSDiscovery11)
            {
                EndpointAddress10.GetSchema(schemaSet);
            }
            else
            {
                Fx.Assert("The discoveryVersion is not supported.");
            }

            // do not add/find Probe related schema items
            SchemaTypes typesFound = SchemaTypes.ProbeType | SchemaTypes.ResolveType;
            SchemaElements elementsFound = SchemaElements.None;         

            XmlSchema discoverySchema = null;
            ICollection discoverySchemas = schemaSet.Schemas(discoveryVersion.Namespace);
            if ((discoverySchemas == null) || (discoverySchemas.Count == 0))
            {
                discoverySchema = CreateSchema(discoveryVersion);
                AddImport(discoverySchema, discoveryVersion.Implementation.WsaNamespace);
                schemaSet.Add(discoverySchema);
            }
            else
            {                
                foreach (XmlSchema schema in discoverySchemas)
                {
                    discoverySchema = schema;
                    if (schema.SchemaTypes.Contains(discoveryVersion.Implementation.QualifiedNames.ProbeMatchType))
                    {
                        typesFound |= SchemaTypes.ProbeMatchType;
                        break;
                    }

                    LocateSchemaTypes(discoveryVersion, schema, ref typesFound);
                    LocateSchemaElements(discoveryVersion, schema, ref elementsFound);
                }
            }

            if ((typesFound & SchemaTypes.ProbeMatchType) != SchemaTypes.ProbeMatchType)
            {
                AddSchemaTypes(discoveryVersion, typesFound, discoverySchema);
                AddElements(discoveryVersion, elementsFound, discoverySchema);
                schemaSet.Reprocess(discoverySchema);
            }

            return discoveryVersion.Implementation.QualifiedNames.ProbeMatchType;
        }
Пример #12
0
		static ContractDescription GetContract (DiscoveryVersion discoveryVersion, ServiceDiscoveryMode mode)
		{
			if (discoveryVersion == null)
				throw new ArgumentNullException ("discoveryVersion");
			// Provide different contract type for Adhoc mode and Managed mode, respectively.
			if (mode == ServiceDiscoveryMode.Managed)
				return ContractDescription.GetContract (discoveryVersion.DiscoveryProxyContractType);
			else
				return ContractDescription.GetContract (discoveryVersion.DiscoveryTargetContractType);
		}
        public AnnouncementEndpoint(DiscoveryVersion discoveryVersion, Binding binding, EndpointAddress address)
            : base(GetAnnouncementContract(discoveryVersion))
        {
            // Send replies async to maintain performance
            this.EndpointBehaviors.Add(new DispatcherSynchronizationBehavior { AsynchronousSendEnabled = true });

            this.discoveryVersion = discoveryVersion;
            base.Address = address;
            base.Binding = binding;
        }
        public DiscoveryEndpoint(DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode, Binding binding, EndpointAddress endpointAddress)
            : base(GetDiscoveryContract(discoveryVersion, discoveryMode))
        {
            base.IsSystemEndpoint = true;
                           
            this.discoveryOperationContextExtension = new DiscoveryOperationContextExtension(TimeSpan.Zero, discoveryMode, discoveryVersion);

            base.Behaviors.Add(new DiscoveryOperationContextExtensionInitializer(this.discoveryOperationContextExtension));
            base.Behaviors.Add(new DiscoveryEndpointValidator());

            base.Address = endpointAddress;
            base.Binding = binding;
        }
        public UdpAnnouncementEndpoint(DiscoveryVersion discoveryVersion, Uri multicastAddress)
            : base(discoveryVersion)
        {
            if (multicastAddress == null)
            {
                throw FxTrace.Exception.ArgumentNull("multicastAddress");
            }
            if (discoveryVersion == null)
            {
                throw FxTrace.Exception.ArgumentNull("discoveryVersion");
            }

            Initialize(multicastAddress);
        }
        public UdpDiscoveryEndpoint(DiscoveryVersion discoveryVersion, Uri multicastAddress)
            : base(discoveryVersion, ServiceDiscoveryMode.Adhoc)
        {
            if (multicastAddress == null)
            {
                throw FxTrace.Exception.ArgumentNull("multicastAddress");
            }
            if (discoveryVersion == null)
            {
                throw FxTrace.Exception.ArgumentNull("discoveryVersion");
            }

            // Send replies async to maintain performance
            base.Behaviors.Add(new DispatcherSynchronizationBehavior { AsynchronousSendEnabled = true });

            Initialize(multicastAddress);
        }
Пример #17
0
        public ProtocolSettings(DiscoveryVersion discoveryVersion)
        {
            Utility.IfNullThrowNullArgumentException(discoveryVersion, "discoveryVersion");
            this.DiscoveryNamespace = discoveryVersion.Namespace;
            this.DiscoveryPrefix = ProtocolStrings.DiscoveryPrefix;

            if (discoveryVersion.Namespace == ProtocolStrings.DiscoveryNamespaceApril2005)
            {
                this.AddressingNamespace = ProtocolStrings.WsaNamespaceAugust2004;
                this.SchemeUri = ProtocolStrings.SchemeUriAugust2004;
                this.SupportsInclusivePrefixes = false;
            }
            else
            {
                this.AddressingNamespace = ProtocolStrings.WsaNamespace10;
                this.SchemeUri = ProtocolStrings.SchemeUri11;
                this.SupportsInclusivePrefixes = true;
            }
        }
Пример #18
0
		internal static EndpointDiscoveryMetadata ReadXml (XmlReader reader, DiscoveryVersion version)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			var ret = new EndpointDiscoveryMetadata ();

			reader.MoveToContent ();

			reader.ReadStartElement ();
			reader.MoveToContent ();

			// standard members
			reader.MoveToContent ();

			// it is possible due to InternalVisibleToAttribute...
			string addrNS = version.MessageVersion.Addressing.Namespace;

			ret.Address = EndpointAddress.ReadFrom (version.MessageVersion.Addressing, reader, "EndpointReference", addrNS);

			reader.MoveToContent ();
			if (reader.IsStartElement ("Types", version.Namespace))
				ret.ContractTypeNames = new Collection<XmlQualifiedName> ((XmlQualifiedName []) reader.ReadElementContentAs (typeof (XmlQualifiedName []), null, "Types", version.Namespace));

			reader.MoveToContent ();
			if (reader.IsStartElement ("Scopes", version.Namespace))
				ret.Scopes = new Collection<Uri> ((Uri []) reader.ReadElementContentAs (typeof (Uri []), null, "Scopes", version.Namespace));

			if (reader.IsStartElement ("XAddrs", version.Namespace))
				ret.ListenUris = new Collection<Uri> ((Uri []) reader.ReadElementContentAs (typeof (Uri []), null, "XAddrs", version.Namespace));

			if (reader.IsStartElement ("MetadataVersion", version.Namespace))
				ret.Version = reader.ReadElementContentAsInt ();

			// non-standard members
			for (reader.MoveToContent (); !reader.EOF && reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ())
				ret.Extensions.Add (XElement.Load (reader));

			reader.ReadEndElement ();

			return ret;
		}
Пример #19
0
        public static XmlQualifiedName EnsureProbeSchema(DiscoveryVersion discoveryVersion, XmlSchemaSet schemaSet)
        {
            Fx.Assert(schemaSet != null, "The schemaSet must be non null.");
            Fx.Assert(discoveryVersion != null, "The discoveryVersion must be non null.");

            // do not find/add ProbeMatch related schema items
            SchemaTypes typesFound = SchemaTypes.ProbeMatchType | SchemaTypes.ResolveType;
            SchemaElements elementsFound = SchemaElements.XAddrs | SchemaElements.MetadataVersion;         

            XmlSchema discoverySchema = null;
            ICollection discoverySchemas = schemaSet.Schemas(discoveryVersion.Namespace);
            if ((discoverySchemas == null) || (discoverySchemas.Count == 0))
            {
                discoverySchema = CreateSchema(discoveryVersion);
                schemaSet.Add(discoverySchema);
            }
            else
            {
                foreach (XmlSchema schema in discoverySchemas)
                {
                    discoverySchema = schema;
                    if (schema.SchemaTypes.Contains(discoveryVersion.Implementation.QualifiedNames.ProbeType))
                    {
                        typesFound |= SchemaTypes.ProbeType;
                        break;
                    }

                    LocateSchemaTypes(discoveryVersion, schema, ref typesFound);
                    LocateSchemaElements(discoveryVersion, schema, ref elementsFound);
                }
            }

            if ((typesFound & SchemaTypes.ProbeType) != SchemaTypes.ProbeType)
            {
                AddSchemaTypes(discoveryVersion, typesFound, discoverySchema);
                AddElements(discoveryVersion, elementsFound, discoverySchema);
                schemaSet.Reprocess(discoverySchema);
            }

            return discoveryVersion.Implementation.QualifiedNames.ProbeType;
        }
        void Intitialize(DiscoveryVersion discoveryVersion, SigningCertificateSettings signingStoreSettings)
        {
            Utility.IfNullThrowNullArgumentException(signingStoreSettings, "signingStoreSettings");

            this.secureBindingElement = new CompactSignatureSecurityBindingElement(
                discoveryVersion,
                signingStoreSettings);

            Binding binding = base.Binding;
            CustomBinding customBinding = binding as CustomBinding;
            if (customBinding == null)
            {
                customBinding = new CustomBinding(binding);
                customBinding.Elements.Insert(0, secureBindingElement);
                base.Binding = customBinding;
            }
            else
            {
                customBinding.Elements.Insert(0, secureBindingElement);
            }
        }
Пример #21
0
		internal static EndpointDiscoveryMetadata ReadXml (XmlReader reader, DiscoveryVersion version)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			var ret = new EndpointDiscoveryMetadata ();

			reader.MoveToContent ();
			if (!reader.IsStartElement ("ProbeMatchType", version.Namespace) || reader.IsEmptyElement)
				throw new XmlException ("Non-empty ProbeMatchType element is expected");
			reader.ReadStartElement ("ProbeType", version.Namespace);

			// standard members
			reader.MoveToContent ();
			ret.Address = EndpointAddress.ReadFrom (AddressingVersion.WSAddressing10, reader);

			reader.MoveToContent ();
			bool isEmpty = reader.IsEmptyElement;
			ret.ContractTypeNames = new Collection<XmlQualifiedName> ((XmlQualifiedName []) reader.ReadElementContentAs (typeof (XmlQualifiedName []), null, "Types", version.Namespace));

			reader.MoveToContent ();
			if (reader.IsStartElement ("Scopes", version.Namespace))
				ret.Scopes = new Collection<Uri> ((Uri []) reader.ReadElementContentAs (typeof (Uri []), null, "Scopes", version.Namespace));

			if (reader.IsStartElement ("XAddrs", version.Namespace))
				ret.ListenUris = new Collection<Uri> ((Uri []) reader.ReadElementContentAs (typeof (Uri []), null, "XAddrs", version.Namespace));

			if (reader.IsStartElement ("MetadataVersion", version.Namespace))
				ret.Version = reader.ReadElementContentAsInt ();

			// non-standard members
			for (reader.MoveToContent (); !reader.EOF && reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ())
				ret.Extensions.Add (XElement.Load (reader));

			reader.ReadEndElement ();

			return ret;
		}
Пример #22
0
		internal void WriteXml (XmlWriter writer, DiscoveryVersion version)
		{
			if (writer == null)
				throw new ArgumentNullException ("writer");

			// standard members
			Address.WriteTo (AddressingVersion.WSAddressing10, writer);

			writer.WriteStartElement ("d", "Types", version.Namespace);
			int p = 0;
			foreach (var qname in ContractTypeNames)
				if (writer.LookupPrefix (qname.Namespace) == null)
					writer.WriteAttributeString ("xmlns", "p" + p++, "http://www.w3.org/2000/xmlns/", qname.Namespace);
			writer.WriteValue (ContractTypeNames);
			writer.WriteEndElement ();

			if (Scopes.Count > 0) {
				writer.WriteStartElement ("Scopes", version.Namespace);
				writer.WriteValue (Scopes);
				writer.WriteEndElement ();
			}

			if (ListenUris.Count > 0) {
				writer.WriteStartElement ("XAddrs", version.Namespace);
				writer.WriteValue (ListenUris);
				writer.WriteEndElement ();
			}
			
			writer.WriteStartElement ("MetadataVersion", version.Namespace);
			writer.WriteValue (Version);
			writer.WriteEndElement ();

			// non-standard members

			foreach (var ext in Extensions)
				ext.WriteTo (writer);
		}
Пример #23
0
 static void LocateSchemaTypes(DiscoveryVersion discoveryVersion, XmlSchema schema, ref SchemaTypes typesFound)
 {
     if (((typesFound & SchemaTypes.QNameListType) != SchemaTypes.QNameListType) &&
         (schema.SchemaTypes.Contains(discoveryVersion.Implementation.QualifiedNames.QNameListType)))
     {
         typesFound |= SchemaTypes.QNameListType;
     }
     if (((typesFound & SchemaTypes.UriListType) != SchemaTypes.UriListType) &&
         (schema.SchemaTypes.Contains(discoveryVersion.Implementation.QualifiedNames.UriListType)))
     {
         typesFound |= SchemaTypes.UriListType;
     }
     if (((typesFound & SchemaTypes.ScopesType) != SchemaTypes.ScopesType) &&
         (schema.SchemaTypes.Contains(discoveryVersion.Implementation.QualifiedNames.ScopesType)))
     {
         typesFound |= SchemaTypes.ScopesType;
     }
 }
 public AnnouncementEndpoint(DiscoveryVersion discoveryVersion)
     : this(discoveryVersion, null, null)
 {
 }
Пример #25
0
		internal static XmlSchema BuildSchema (DiscoveryVersion version)
		{
			var schema = new XmlSchema () { TargetNamespace = version.Namespace };

			var anyAttr = new XmlSchemaAnyAttribute () { Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax };

			var probePart = new XmlSchemaSequence ();
			probePart.Items.Add (new XmlSchemaElement () { RefName = new XmlQualifiedName ("Types", version.Namespace), MinOccurs = 0 });
			probePart.Items.Add (new XmlSchemaElement () { RefName = new XmlQualifiedName ("Scopes", version.Namespace), MinOccurs = 0 });
			probePart.Items.Add (new XmlSchemaAny () { MinOccurs = 0, MaxOccursString = "unbounded", Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax });
			var ct = new XmlSchemaComplexType () { Name = "ProbeType", Particle = probePart, AnyAttribute = anyAttr };
			schema.Items.Add (ct);

			schema.Items.Add (new XmlSchemaSimpleType () { Name = "QNameListType", Content = new XmlSchemaSimpleTypeList () { ItemTypeName = new XmlQualifiedName ("QName", XmlSchema.Namespace) } });

			var scr = new XmlSchemaSimpleContentRestriction () { BaseTypeName = new XmlQualifiedName ("UriListType", version.Namespace), AnyAttribute = anyAttr };
			scr.Attributes.Add (new XmlSchemaAttribute () { Name = "matchBy", SchemaTypeName = new XmlQualifiedName ("anyURI", XmlSchema.Namespace) });
			schema.Items.Add (new XmlSchemaComplexType () { Name = "ScopesType", ContentModel = new XmlSchemaSimpleContent () { Content = scr } });

			schema.Items.Add (new XmlSchemaSimpleType () { Name = "UriListType", Content = new XmlSchemaSimpleTypeList () { ItemTypeName = new XmlQualifiedName ("anyURI", XmlSchema.Namespace) } });

			schema.Items.Add (new XmlSchemaElement () { Name = "Types", SchemaTypeName = new XmlQualifiedName ("QNameListType", version.Namespace) });
			schema.Items.Add (new XmlSchemaElement () { Name = "Scopes", SchemaTypeName = new XmlQualifiedName ("ScopesType", version.Namespace) });

			return schema;
		}
        internal static XmlSchema BuildSchema(DiscoveryVersion version)
        {
            var schema = new XmlSchema()
            {
                TargetNamespace = version.Namespace
            };

            var anyAttr = new XmlSchemaAnyAttribute()
            {
                Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax
            };

            var probePart = new XmlSchemaSequence();

            probePart.Items.Add(new XmlSchemaElement()
            {
                RefName = new XmlQualifiedName("Types", version.Namespace), MinOccurs = 0
            });
            probePart.Items.Add(new XmlSchemaElement()
            {
                RefName = new XmlQualifiedName("Scopes", version.Namespace), MinOccurs = 0
            });
            probePart.Items.Add(new XmlSchemaAny()
            {
                MinOccurs = 0, MaxOccursString = "unbounded", Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax
            });
            var ct = new XmlSchemaComplexType()
            {
                Name = "ProbeType", Particle = probePart, AnyAttribute = anyAttr
            };

            schema.Items.Add(ct);

            schema.Items.Add(new XmlSchemaSimpleType()
            {
                Name = "QNameListType", Content = new XmlSchemaSimpleTypeList()
                {
                    ItemTypeName = new XmlQualifiedName("QName", XmlSchema.Namespace)
                }
            });

            var scr = new XmlSchemaSimpleContentRestriction()
            {
                BaseTypeName = new XmlQualifiedName("UriListType", version.Namespace), AnyAttribute = anyAttr
            };

            scr.Attributes.Add(new XmlSchemaAttribute()
            {
                Name = "matchBy", SchemaTypeName = new XmlQualifiedName("anyURI", XmlSchema.Namespace)
            });
            schema.Items.Add(new XmlSchemaComplexType()
            {
                Name = "ScopesType", ContentModel = new XmlSchemaSimpleContent()
                {
                    Content = scr
                }
            });

            schema.Items.Add(new XmlSchemaSimpleType()
            {
                Name = "UriListType", Content = new XmlSchemaSimpleTypeList()
                {
                    ItemTypeName = new XmlQualifiedName("anyURI", XmlSchema.Namespace)
                }
            });

            schema.Items.Add(new XmlSchemaElement()
            {
                Name = "Types", SchemaTypeName = new XmlQualifiedName("QNameListType", version.Namespace)
            });
            schema.Items.Add(new XmlSchemaElement()
            {
                Name = "Scopes", SchemaTypeName = new XmlQualifiedName("ScopesType", version.Namespace)
            });

            return(schema);
        }
Пример #27
0
 // (2)->(6)
 public UdpAnnouncementEndpoint(DiscoveryVersion discoveryVersion)
     : this(discoveryVersion, DefaultMulticastAddress)
 {
 }
Пример #28
0
		// (5)->(6)
		public UdpAnnouncementEndpoint (DiscoveryVersion discoveryVersion, string multicastAddress)
			: this (discoveryVersion, new Uri (multicastAddress))
		{
		}
Пример #29
0
 // (5)->(6)
 public UdpAnnouncementEndpoint(DiscoveryVersion discoveryVersion, string multicastAddress)
     : this(discoveryVersion, new Uri(multicastAddress))
 {
 }
Пример #30
0
		public DiscoveryEndpoint (DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode)
			: this (discoveryVersion, discoveryMode, null, null)
		{
		}
Пример #31
0
 public static void WriteMetadataVersion(DiscoveryVersion discoveryVersion, int metadataVersion, XmlWriter writer)
 {
     writer.WriteStartElement(ProtocolStrings.SchemaNames.MetadataVersionElement, discoveryVersion.Namespace);
     writer.WriteValue(metadataVersion);
     writer.WriteEndElement();
 }
Пример #32
0
		internal void WriteXml (XmlWriter writer, DiscoveryVersion version)
		{
			if (writer == null)
				throw new ArgumentNullException ("writer");

			// standard members
			writer.WriteStartElement ("d", "Types", version.Namespace);
			int p = 0;
			foreach (var qname in ContractTypeNames)
				if (writer.LookupPrefix (qname.Namespace) == null)
					writer.WriteAttributeString ("xmlns", "p" + p++, "http://www.w3.org/2000/xmlns/", qname.Namespace);
			writer.WriteValue (ContractTypeNames);
			writer.WriteEndElement ();

			writer.WriteStartElement ("Scopes", version.Namespace);
			if (ScopeMatchBy != null) {
				writer.WriteStartAttribute ("MatchBy");
				writer.WriteValue (ScopeMatchBy);
				writer.WriteEndAttribute ();
			}
			writer.WriteValue (Scopes);
			writer.WriteEndElement ();

			// non-standard members
			if (MaxResults != default_max_results) {
				writer.WriteStartElement ("MaxResults", SerializationNS);
				writer.WriteValue (MaxResults);
				writer.WriteEndElement ();
			}
			writer.WriteStartElement ("Duration", SerializationNS);
			writer.WriteValue (Duration);
			writer.WriteEndElement ();
			
			foreach (var ext in Extensions)
				ext.WriteTo (writer);
		}
Пример #33
0
 public DiscoveryEndpoint(DiscoveryVersion discoveryVersion, ServiceDiscoveryMode discoveryMode)
     : this(discoveryVersion, discoveryMode, null, null)
 {
 }
Пример #34
0
		internal static FindCriteria ReadXml (XmlReader reader, DiscoveryVersion version)
		{
			if (reader == null)
				throw new ArgumentNullException ("reader");

			var ret = new FindCriteria ();

			reader.MoveToContent ();
			if (!reader.IsStartElement ("Probe", version.Namespace) || reader.IsEmptyElement)
				throw new XmlException (String.Format ("Non-empty ProbeType element is expected. Got '{0}' {1} node in namespace '{2}' instead.", reader.LocalName, reader.NodeType, reader.NamespaceURI));
			reader.ReadStartElement ("Probe", version.Namespace);

			// standard members
			reader.MoveToContent ();
			if (reader.IsStartElement ("Types", version.Namespace))
				ret.ContractTypeNames = new Collection<XmlQualifiedName> ((XmlQualifiedName []) reader.ReadElementContentAs (typeof (XmlQualifiedName []), null, "Types", version.Namespace));

			reader.MoveToContent ();
			if (reader.IsStartElement ("Types", version.Namespace)) {
				if (reader.MoveToAttribute ("MatchBy")) {
					ret.ScopeMatchBy = new Uri (reader.Value, UriKind.RelativeOrAbsolute);
					reader.MoveToElement ();
				}
				ret.Scopes = new Collection<Uri> ((Uri []) reader.ReadElementContentAs (typeof (Uri []), null, "Scopes", version.Namespace));
			}

			// non-standard members
			for (reader.MoveToContent (); !reader.EOF && reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
				if (reader.NamespaceURI == SerializationNS) {
					switch (reader.LocalName) {
					case "MaxResults":
						ret.MaxResults = reader.ReadElementContentAsInt ();
						break;
					case "Duration":
						ret.Duration = (TimeSpan) reader.ReadElementContentAs (typeof (TimeSpan), null);
						break;
					}
				}
				else
					ret.Extensions.Add (XElement.Load (reader));
			}

			reader.ReadEndElement ();

			return ret;
		}
Пример #35
0
 // (2)->(6)
 public UdpDiscoveryEndpoint(DiscoveryVersion discoveryVersion)
     : this(discoveryVersion, DefaultMulticastAddress)
 {
 }
Пример #36
0
        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();
        }
Пример #37
0
        static void AddProbeMatchType(DiscoveryVersion discoveryVersion, XmlSchema schema)
        {
            // <xs:complexType name="ProbeMatchType">
            XmlSchemaComplexType probeMatchType = new XmlSchemaComplexType();

            probeMatchType.Name = ProtocolStrings.SchemaNames.ProbeMatchType;

            //   <xs:sequence>
            XmlSchemaSequence probeMatcheSequence = new XmlSchemaSequence();

            //     <xs:element ref="wsa:EndpointReference" />
            XmlSchemaElement eprElement = new XmlSchemaElement();

            eprElement.RefName = discoveryVersion.Implementation.QualifiedNames.EprElement;

            //     <xs:element minOccurs="0" ref="tns:Types" />
            XmlSchemaElement typesElement = new XmlSchemaElement();

            typesElement.RefName   = discoveryVersion.Implementation.QualifiedNames.TypesElement;
            typesElement.MinOccurs = 0;

            //     <xs:element minOccurs="0" ref="tns:Scopes" />
            XmlSchemaElement scopesElement = new XmlSchemaElement();

            scopesElement.RefName   = discoveryVersion.Implementation.QualifiedNames.ScopesElement;
            scopesElement.MinOccurs = 0;

            //     <xs:element minOccurs="0" ref="tns:XAddrs" />
            XmlSchemaElement xAddrsElement = new XmlSchemaElement();

            xAddrsElement.RefName   = discoveryVersion.Implementation.QualifiedNames.XAddrsElement;
            xAddrsElement.MinOccurs = 0;

            //     <xs:element ref="tns:MetadataVersion" /> -- allowing minOccurs=0 because the same type is used for Bye messages
            XmlSchemaElement metadataVersionElement = new XmlSchemaElement();

            metadataVersionElement.RefName   = discoveryVersion.Implementation.QualifiedNames.MetadataVersionElement;
            metadataVersionElement.MinOccurs = 0;

            //     <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax" />
            XmlSchemaAny any = new XmlSchemaAny();

            any.Namespace       = "##other";
            any.ProcessContents = XmlSchemaContentProcessing.Lax;
            any.MinOccurs       = 0;
            any.MaxOccurs       = decimal.MaxValue;

            //   </xs:sequence>
            probeMatcheSequence.Items.Add(eprElement);
            probeMatcheSequence.Items.Add(typesElement);
            probeMatcheSequence.Items.Add(scopesElement);
            probeMatcheSequence.Items.Add(xAddrsElement);
            probeMatcheSequence.Items.Add(metadataVersionElement);
            probeMatcheSequence.Items.Add(any);

            //   <xs:anyAttribute namespace="##other" processContents="lax" />
            XmlSchemaAnyAttribute anyAttribue = new XmlSchemaAnyAttribute();

            anyAttribue.Namespace       = "##other";
            anyAttribue.ProcessContents = XmlSchemaContentProcessing.Lax;

            // </xs:complexType>
            probeMatchType.Particle     = probeMatcheSequence;
            probeMatchType.AnyAttribute = anyAttribue;

            schema.Items.Add(probeMatchType);
        }
Пример #38
0
		// (2)->(6)
		public UdpAnnouncementEndpoint (DiscoveryVersion discoveryVersion)
			: this (discoveryVersion, DefaultMulticastAddress)
		{
		}
Пример #39
0
 public AnnouncementEndpoint(DiscoveryVersion discoveryVersion, Binding binding, EndpointAddress address)
     : base(GetContract(discoveryVersion), binding, address)
 {
     DiscoveryVersion = discoveryVersion;
 }
        internal static FindCriteria ReadXml(XmlReader reader, DiscoveryVersion version)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            var ret = new FindCriteria();

            reader.MoveToContent();
            if (!reader.IsStartElement("Probe", version.Namespace) || reader.IsEmptyElement)
            {
                throw new XmlException(String.Format("Non-empty ProbeType element is expected. Got '{0}' {1} node in namespace '{2}' instead.", reader.LocalName, reader.NodeType, reader.NamespaceURI));
            }
            reader.ReadStartElement("Probe", version.Namespace);

            // standard members
            reader.MoveToContent();
            if (reader.IsStartElement("Types", version.Namespace))
            {
                ret.ContractTypeNames = new Collection <XmlQualifiedName> ((XmlQualifiedName [])reader.ReadElementContentAs(typeof(XmlQualifiedName []), null, "Types", version.Namespace));
            }

            reader.MoveToContent();
            if (reader.IsStartElement("Types", version.Namespace))
            {
                if (reader.MoveToAttribute("MatchBy"))
                {
                    ret.ScopeMatchBy = new Uri(reader.Value, UriKind.RelativeOrAbsolute);
                    reader.MoveToElement();
                }
            }
            if (reader.IsStartElement("Scopes", version.Namespace))
            {
                ret.Scopes = new Collection <Uri> ((Uri [])reader.ReadElementContentAs(typeof(Uri []), null, "Scopes", version.Namespace));
            }

            // non-standard members
            for (reader.MoveToContent(); !reader.EOF && reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent())
            {
                if (reader.NamespaceURI == SerializationNS)
                {
                    switch (reader.LocalName)
                    {
                    case "MaxResults":
                        ret.MaxResults = reader.ReadElementContentAsInt();
                        break;

                    case "Duration":
                        ret.Duration = (TimeSpan)reader.ReadElementContentAs(typeof(TimeSpan), null);
                        break;
                    }
                }
                else
                {
                    ret.Extensions.Add(XElement.Load(reader));
                }
            }

            reader.ReadEndElement();

            return(ret);
        }
Пример #41
0
 public AnnouncementEndpoint(DiscoveryVersion discoveryVersion)
     : this(discoveryVersion, null, null)
 {
 }