Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DeviceDescriptionDocument.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Xml;
5
7{
12 {
13 private readonly XmlDocument xml;
14 private readonly UPnPDevice device;
15 private readonly int majorVersion;
16 private readonly int minorVersion;
17 private readonly string baseUrl;
18 private readonly Uri baseUri;
19
20 internal DeviceDescriptionDocument(XmlDocument Xml, UPnPClient Client, string BaseUrl)
21 {
22 this.xml = Xml;
23
24 if (!(Xml.DocumentElement is null) && Xml.DocumentElement.LocalName == "root" &&
25 Xml.DocumentElement.NamespaceURI == "urn:schemas-upnp-org:device-1-0")
26 {
27 if (!string.IsNullOrEmpty(BaseUrl))
28 {
29 this.baseUrl = BaseUrl;
30 this.baseUri = new Uri(this.baseUrl);
31 }
32
33 foreach (XmlNode N in Xml.DocumentElement.ChildNodes)
34 {
35 switch (N.LocalName)
36 {
37 case "specVersion":
38 foreach (XmlNode N2 in N.ChildNodes)
39 {
40 switch (N2.LocalName)
41 {
42 case "major":
43 this.majorVersion = int.Parse(N2.InnerText);
44 break;
45
46 case "minor":
47 this.minorVersion = int.Parse(N2.InnerText);
48 break;
49 }
50 }
51 break;
52
53 case "URLBase":
54 this.baseUrl = N.InnerText;
55 this.baseUri = new Uri(this.baseUrl);
56 break;
57
58 case "device":
59 this.device = new UPnPDevice((XmlElement)N, this.baseUri, Client);
60 break;
61 }
62 }
63 }
64 else
65 throw new Exception("Unrecognized file format.");
66 }
67
71 public XmlDocument Xml => this.xml;
72
76 public int MajorVersion => this.majorVersion;
77
81 public int MinorVersion => this.minorVersion;
82
86 public string BaseUrl => this.baseUrl;
87
91 public Uri BaseUri => this.baseUri;
92
96 public UPnPDevice Device => this.device;
97
99 public override string ToString()
100 {
101 return this.baseUrl;
102 }
103
109 public UPnPDevice GetDevice(string DeviceType)
110 {
111 if (this.device is null)
112 return null;
113 else
114 return this.device.GetDevice(DeviceType);
115 }
116
122 public UPnPService GetService(string ServiceType)
123 {
124 if (this.device is null)
125 return null;
126 else
127 return this.device.GetService(ServiceType);
128 }
129
134 {
135 get
136 {
137 return this.device.DevicesRecursive;
138 }
139 }
140
145 {
146 get
147 {
148 return this.device.ServicesRecursive;
149 }
150 }
151
152 }
153}
Contains the information provided in a Device Description Document, downloaded from a device in the n...
UPnPService GetService(string ServiceType)
Gets a service, given its service type.
UPnPDevice[] DevicesRecursive
Returns all devices, including the root device itself and its embedded devices, and their embedded de...
UPnPService[] ServicesRecursive
Returns all services, including the service of itself and services of its embedded devices,...
UPnPDevice GetDevice(string DeviceType)
Gets a device or embedded device, given its device type.
Implements support for the UPnP protocol, as described in: http://upnp.org/specs/arch/UPnP-arch-Devic...
Definition: UPnPClient.cs:21
Contains information about a device.
Definition: UPnPDevice.cs:12
UPnPDevice GetDevice(string DeviceType)
Gets a device or embedded device, given its device type.
Definition: UPnPDevice.cs:233
UPnPDevice[] DevicesRecursive
Returns all devices, including the device itself and its embedded devices, and their embedded devices...
Definition: UPnPDevice.cs:281
Contains information about a service.
Definition: UPnPService.cs:12
ServiceDescriptionDocument GetService()
Gets the service description document from a service in the network. This method is the synchronous v...
Definition: UPnPService.cs:144