2using System.Collections.Generic;
3using System.Threading.Tasks;
13 private readonly Dictionary<string, UPnPAction> actionsByName =
new Dictionary<string, UPnPAction>();
14 private readonly Dictionary<string, UPnPStateVariable> variablesByName =
new Dictionary<string, UPnPStateVariable>();
18 private readonly XmlDocument xml;
19 private readonly
int majorVersion;
20 private readonly
int minorVersion;
24 List<UPnPStateVariable>
Variables =
new List<UPnPStateVariable>();
25 List<UPnPAction>
Actions =
new List<UPnPAction>();
29 if (!(
Xml.DocumentElement is
null) &&
Xml.DocumentElement.LocalName ==
"scpd" &&
30 Xml.DocumentElement.NamespaceURI ==
"urn:schemas-upnp-org:service-1-0")
32 foreach (XmlNode N
in Xml.DocumentElement.ChildNodes)
37 foreach (XmlNode N2
in N.ChildNodes)
42 this.majorVersion =
int.Parse(N2.InnerText);
46 this.minorVersion =
int.Parse(N2.InnerText);
53 foreach (XmlNode N2
in N.ChildNodes)
55 if (N2.LocalName ==
"action")
59 this.actionsByName[Action.Name] = Action;
64 case "serviceStateTable":
65 foreach (XmlNode N2
in N.ChildNodes)
67 if (N2.LocalName ==
"stateVariable")
71 this.variablesByName[Variable.
Name] = Variable;
79 throw new Exception(
"Unrecognized file format.");
81 this.actions =
Actions.ToArray();
88 public XmlDocument
Xml => this.xml;
122 if (this.actionsByName.TryGetValue(Name, out
UPnPAction Action))
149 public Task<KeyValuePair<object, Dictionary<string, object>>>
InvokeAsync(
string ActionName,
int Timeout, params KeyValuePair<string, object>[] InputValues)
153 throw new ArgumentException(
"Action not found: " + ActionName, nameof(ActionName));
155 return Action.InvokeAsync(Timeout, InputValues);
166 public Task<KeyValuePair<object, Dictionary<string, object>>>
InvokeAsync(
string ActionName, Dictionary<string, object> InputValues,
int Timeout)
170 throw new ArgumentException(
"Action not found: " + ActionName, nameof(ActionName));
172 return Action.InvokeAsync(InputValues, Timeout);
Contains the information provided in a Service Description Document, downloaded from a service in the...
Task< KeyValuePair< object, Dictionary< string, object > > > InvokeAsync(string ActionName, int Timeout, params KeyValuePair< string, object >[] InputValues)
Invokes an action.
UPnPService Service
Parent service object.
int MinorVersion
Minor version
int MajorVersion
Major version
UPnPAction[] Actions
Service Actions.
UPnPAction GetAction(string Name)
Gets an action, given its name. If not found, null is returned.
XmlDocument Xml
Underlying XML Document.
UPnPStateVariable[] Variables
State variables.
UPnPStateVariable GetVariable(string Name)
Gets an action, given its name. If not found, null is returned.
Task< KeyValuePair< object, Dictionary< string, object > > > InvokeAsync(string ActionName, Dictionary< string, object > InputValues, int Timeout)
Invokes an action.
Contains information about an action.
Implements support for the UPnP protocol, as described in: http://upnp.org/specs/arch/UPnP-arch-Devic...
Contains information about a service.
Contains information about a state variable.
string Name
State Variable Name