} // AddStateVariable() /// <summary> /// Updates the properties on this service with the information /// of the given service. /// </summary> /// <param name="service">The service.</param> public void UpdateServiceInfo(UpnpService service) { foreach (var action in service.Actions) { this.actions.Add(action); } // foreach foreach (var variable in service.StateVariables) { this.stateVariables.Add(variable); } // foreach } // UpdateServiceInfo()
} // ParseDeviceSchema() /// <summary> /// Parses the service schema. /// </summary> /// <param name="text">The text.</param> /// <returns>A <see cref="UpnpService"/> object.</returns> public static UpnpService ParseServiceSchema(string text) { var service = new UpnpService(); if (string.IsNullOrEmpty(text)) { return(service); } // if var document = XDocument.Parse(text); var nodes = document.Elements().Where(e => e.Name.LocalName == "scpd"); var xroot = nodes.FirstOrDefault(); if (xroot == null) { throw new XmlException("No node 'scpd' found!"); } // if CheckSupportedSpecVersion(xroot, 1, 0); var xactionList = XmlSupport.GetFirstSubNode(xroot, "actionList", false); if (xactionList != null) { var actionList = from xaction in xactionList.Elements() where (xaction.Name.LocalName == "action") select xaction; foreach (var xaction in actionList) { var action = ParseAction(xaction); action.Service = service; service.AddAction(action); } // foreach } // if var xserviceStateTable = XmlSupport.GetFirstSubNode(xroot, "serviceStateTable"); if (xserviceStateTable != null) { var serviceStateTable = from xvariable in xserviceStateTable.Elements() where (xvariable.Name.LocalName == "stateVariable") select xvariable; foreach (var xvariable in serviceStateTable) { var variable = ParseStateVariable(xvariable); service.AddStateVariable(variable); } // foreach } // if return(service); } // ParseServiceSchema()
} // ParseArgument() /// <summary> /// Parses the device schema. /// </summary> /// <param name="xdevice">The parent element.</param> /// <returns>A <see cref="DeviceSchema"/> object.</returns> private static DeviceSchema ParseDeviceSchema(XContainer xdevice) { var schema = new DeviceSchema(); schema.DeviceType = XmlSupport.GetFirstSubNodeValue(xdevice, "deviceType"); schema.FriendlyName = XmlSupport.GetFirstSubNodeValue(xdevice, "friendlyName"); schema.Manufacturer = XmlSupport.GetFirstSubNodeValue(xdevice, "manufacturer"); schema.ManufacturerUrl = XmlSupport.GetFirstSubNodeValue(xdevice, "manufacturerURL", false); schema.ModelDescription = XmlSupport.GetFirstSubNodeValue(xdevice, "modelDescription", false); schema.ModelName = XmlSupport.GetFirstSubNodeValue(xdevice, "modelName"); schema.ModelNumber = XmlSupport.GetFirstSubNodeValue(xdevice, "modelNumber", false); schema.ModelUrl = XmlSupport.GetFirstSubNodeValue(xdevice, "modelURL", false); schema.SerialNumber = XmlSupport.GetFirstSubNodeValue(xdevice, "serialNumber", false); schema.UDN = XmlSupport.GetFirstSubNodeValue(xdevice, "UDN"); var xiconList = XmlSupport.GetFirstSubNode(xdevice, "iconList", false); if (xiconList != null) { var iconList = from xicon in xiconList.Elements() where (xicon.Name.LocalName == "icon") select xicon; foreach (var xicon in iconList) { var icon = new DeviceIcon(); icon.MimeType = XmlSupport.GetFirstSubNodeValue(xicon, "mimetype"); icon.Width = int.Parse(XmlSupport.GetFirstSubNodeValue(xicon, "width")); icon.Height = int.Parse(XmlSupport.GetFirstSubNodeValue(xicon, "height")); icon.Depth = int.Parse(XmlSupport.GetFirstSubNodeValue(xicon, "depth")); icon.URL = XmlSupport.GetFirstSubNodeValue(xicon, "url"); schema.AddIcon(icon); } // foreach } // if var xserviceList = XmlSupport.GetFirstSubNode(xdevice, "serviceList"); var serviceList = from xservice in xserviceList.Elements() where (xservice.Name.LocalName == "service") select xservice; foreach (var xservice in serviceList) { var service = new UpnpService(); service.Type = XmlSupport.GetFirstSubNodeValue(xservice, "serviceType"); service.Id = XmlSupport.GetFirstSubNodeValue(xservice, "serviceId"); service.ControlUrl = XmlSupport.GetFirstSubNodeValue(xservice, "controlURL"); service.EventSubURL = XmlSupport.GetFirstSubNodeValue(xservice, "eventSubURL"); service.ScpdUrl = XmlSupport.GetFirstSubNodeValue(xservice, "SCPDURL"); schema.AddService(service); } // foreach var xdeviceList = XmlSupport.GetFirstSubNode(xdevice, "deviceList", false); if (xdeviceList != null) { var deviceList = from xsubDevice in xdeviceList.Elements() where (xsubDevice.Name.LocalName == "device") select xsubDevice; foreach (var xsubDevice in deviceList) { var device = ParseDeviceSchema(xsubDevice); schema.AddSubDevice(device); } // foreach } // if schema.PresentationUrl = XmlSupport.GetFirstSubNodeValue(xdevice, "presentationURL", false); return(schema); } // ParseDeviceSchema()
} // AddIcon() /// <summary> /// Adds the service. /// </summary> /// <param name="service">The service.</param> public void AddService(UpnpService service) { this.services.Add(service); } // AddService()