/// <summary> /// Gets all readable info as text for a device. /// </summary> /// <param name="device">The com device to get the info for.</param> /// <param name="indent">The indent for the information.</param> /// <returns>The readable info for the device.</returns> public static string ReadableInfo(this IUPnPDevice device, int indent = 0) { return(string.Format( "{1}Name: {2} ({3}){0}" + "{1}Description: {4}{0}" + "{1}Manufacturer: {5} ({6}){0}" + "{1}Model: {7} - {8} ({9}){0}" + "{1}Serial: {10}{0}" + "{1}Unique Device Name: {11}{0}" + "{1}UPC: {12}{0}" + "{1}Description URL: {13}{0}" + "{1}Devices{14}" + "{1}Services{15}", Environment.NewLine, new String(' ', indent * 4), device.FriendlyName, device.Type, device.Description, device.ManufacturerName, device.ManufacturerURL, device.ModelName, device.ModelNumber, device.ModelURL, device.SerialNumber, device.UniqueDeviceName, device.UPC, device.GetDocumentURL(), device.Children.ReadableInfo(indent), device.Services.ReadableInfo(indent))); }
/// <summary> /// Gets the root description for a device. /// </summary> /// <param name="device">The device to get the root description.</param> /// <returns>The root description for the device.</returns> public static RootDescription RootDeviceDescription(this IUPnPDevice device) { if (Logging.Enabled) { Logging.Log(device, String.Format("Getting RootDeviceDescription for {0}", device.FriendlyName), 1); } try { string lsURL = device.GetDocumentURL(); if (lsURL.Length > 0) { if (Logging.Enabled) { Logging.Log(device, String.Format("Getting Document URL: '{0}'", lsURL)); } try { using (XmlTextReader lrReader = Utils.GetXMLTextReader(lsURL)) { if (Logging.Enabled) { Logging.Log(device, "Finding start node"); } while (lrReader.Read()) { if (RootDescription.IsStartNodeFor(lrReader)) { break; } } if (RootDescription.IsStartNodeFor(lrReader)) { if (Logging.Enabled) { Logging.Log(device, "Start node found, processing description"); } return(new RootDescription(lsURL, lrReader)); } else { if (Logging.Enabled) { Logging.Log(device, "Start node NOT found"); } return(null); } } } catch (Exception loE) { if (Logging.Enabled) { Logging.Log(device, String.Format("Downloading and processing of URL failed with error: {0}", loE.ToString())); } throw; } } else { if (Logging.Enabled) { Logging.Log(device, String.Format("Document URL Invalid: '{0}'", lsURL)); } return(null); } } finally { if (Logging.Enabled) { Logging.Log(device, System.String.Format("Finished getting RootDeviceDescription for {0}", device.FriendlyName), -1); } } }