internal DeviceDescriptionDocument(XmlDocument Xml, UPnPClient Client, string BaseUrl)
		{
			this.xml = Xml;

			if (Xml.DocumentElement != null && Xml.DocumentElement.LocalName == "root" &&
				Xml.DocumentElement.NamespaceURI == "urn:schemas-upnp-org:device-1-0")
			{
				if (!string.IsNullOrEmpty(BaseUrl))
				{
					this.baseUrl = BaseUrl;
					this.baseUri = new Uri(this.baseUrl);
				}

				foreach (XmlNode N in Xml.DocumentElement.ChildNodes)
				{
					switch (N.LocalName)
					{
						case "specVersion":
							foreach (XmlNode N2 in N.ChildNodes)
							{
								switch (N2.LocalName)
								{
									case "major":
										this.majorVersion = int.Parse(N2.InnerText);
										break;

									case "minor":
										this.minorVersion = int.Parse(N2.InnerText);
										break;
								}
							}
							break;

						case "URLBase":
							this.baseUrl = N.InnerText;
							this.baseUri = new Uri(this.baseUrl);
							break;

						case "device":
							this.device = new UPnPDevice((XmlElement)N, this.baseUri, Client);
							break;
					}
				}
			}
			else
				throw new Exception("Unrecognized file format.");
		}
        internal DeviceDescriptionDocument(XmlDocument Xml, UPnPClient Client, string BaseUrl)
        {
            this.xml = Xml;

            if (!(Xml.DocumentElement is null) && Xml.DocumentElement.LocalName == "root" &&
                Xml.DocumentElement.NamespaceURI == "urn:schemas-upnp-org:device-1-0")
            {
                if (!string.IsNullOrEmpty(BaseUrl))
                {
                    this.baseUrl = BaseUrl;
                    this.baseUri = new Uri(this.baseUrl);
                }

                foreach (XmlNode N in Xml.DocumentElement.ChildNodes)
                {
                    switch (N.LocalName)
                    {
                    case "specVersion":
                        foreach (XmlNode N2 in N.ChildNodes)
                        {
                            switch (N2.LocalName)
                            {
                            case "major":
                                this.majorVersion = int.Parse(N2.InnerText);
                                break;

                            case "minor":
                                this.minorVersion = int.Parse(N2.InnerText);
                                break;
                            }
                        }
                        break;

                    case "URLBase":
                        this.baseUrl = N.InnerText;
                        this.baseUri = new Uri(this.baseUrl);
                        break;

                    case "device":
                        this.device = new UPnPDevice((XmlElement)N, this.baseUri, Client);
                        break;
                    }
                }
            }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a device or embedded device, given its device type.
        /// </summary>
        /// <param name="DeviceType">Device type.</param>
        /// <returns>Device object, if found, null otherwise.</returns>
        public UPnPDevice GetDevice(string DeviceType)
        {
            UPnPDevice Result = null;

            if (this.deviceType == DeviceType)
            {
                Result = this;
            }
            else
            {
                foreach (UPnPDevice Device in this.devices)
                {
                    Result = Device.GetDevice(DeviceType);
                    if (!(Result is null))
                    {
                        break;
                    }
                }
            }

            return(Result);
        }