/// <summary> /// Gets the root description for a reader. /// </summary> /// <param name="documentURL">The URL for this root description.</param> /// <param name="reader">The XML reader to get the root description from.</param> public RootDescription(string documentURL, XmlTextReader reader) : base(null) { msvSpecVersion = new SpecVersionDescription(this); mdDevice = new DeviceDescription(this); msDocumentURL = documentURL; if (IsStartNodeFor(reader)) { msSchema = reader.GetAttribute("xmlns") ?? String.Empty; ProcessReader(reader); } else throw new InvalidOperationException( string.Format( "The node {0} is not a valid node for {1}", reader.Name, this.GetType().Name)); }
/// <summary> /// Gets the device service description for a service. /// </summary> /// <param name="service">The service to get the description for.</param> /// <param name="device">The device to get the description for.</param> /// <param name="rootDescription">The root description for the device.</param> /// <returns>The device service description.</returns> public static DeviceServiceDescription DeviceServiceDescription( this IUPnPService service, IUPnPDevice device, RootDescription rootDescription) { if (Logging.Enabled) { Logging.Log(service, String.Format("Getting DeviceServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), 1); } try { if (Logging.Enabled) { if (Logging.Enabled) { Logging.Log(service, "Using RootDescription:", 1); } try { if (Logging.Enabled) { Logging.Log(service, rootDescription.ToString()); } } finally { if (Logging.Enabled) { Logging.Log(service, "End RootDescription", -1); } } } DeviceServiceDescription ldsdDesc = null; if (rootDescription != null) { if (Logging.Enabled) { Logging.Log(service, string.Format("Finding device by UDN: '{0}'", device.UniqueDeviceName)); } DeviceDescription lddDevice = rootDescription.FindDevice(device.UniqueDeviceName); if (lddDevice != null) { if (Logging.Enabled) { Logging.Log(service, string.Format("Device Found, finding DeviceServiceDescription by Service ID: '{0}'", service.Id)); } if (Logging.Enabled) { if (Logging.Enabled) { Logging.Log(service, "DeviceDescription:", 1); } try { if (Logging.Enabled) { Logging.Log(service, lddDevice.ToString()); } } finally { if (Logging.Enabled) { Logging.Log(service, "End DeviceDescription", -1); } } } lddDevice.DeviceServices.TryGetValue(service.Id, out ldsdDesc); if (ldsdDesc != null) { if (Logging.Enabled) { if (Logging.Enabled) { Logging.Log(service, "DeviceServiceDescription found:", 1); } try { if (Logging.Enabled) { Logging.Log(service, ldsdDesc.ToString()); } } finally { if (Logging.Enabled) { Logging.Log(service, "End DeviceServiceDescription", -1); } } } } else if (Logging.Enabled) { Logging.Log(service, "DeviceServiceDescripton not found"); } } else if (Logging.Enabled) { Logging.Log(service, "Device not found"); } } else if (Logging.Enabled) { Logging.Log(service, "Invalid rootDescription parameter"); } return(ldsdDesc); } finally { if (Logging.Enabled) { Logging.Log(service, String.Format("Finished getting DeviceServiceDescription for {0} -> {1}", device.FriendlyName, service.Id), -1); } } }
/// <summary> /// Creates a new service description. /// </summary> /// <param name="parent">The parent description object, or null if root description.</param> /// <param name="device">The device description which owns the service.</param> /// <param name="reader">The XML reader to get the data for the service from.</param> public DeviceServiceDescription(Description parent, DeviceDescription device, XmlTextReader reader) : base(parent, reader) { mdDevice = device; }
/// <summary> /// Uses an XML node for this description. /// </summary> /// <param name="reader">The XML reader to use the node from.</param> /// <param name="lastNodeName">The last node name.</param> /// <returns>True if the node was processed false otherwise.</returns> protected override bool UseNode(XmlTextReader reader, string lastNodeName) { if (SpecVersionDescription.IsStartNodeFor(reader)) { msvSpecVersion = new SpecVersionDescription(this, reader); return true; } else if (DeviceDescription.IsStartNodeFor(reader)) { mdDevice = new DeviceDescription(this, reader); return true; } return false; }