/// <summary> /// Creates a new list of devices from a native devices list. /// </summary> /// <param name="devices">The native devices to add to the list.</param> /// <param name="interfaceGuid">The network interface Guid for the devices or Guid.Empty is unknown.</param> internal Devices(IUPnPDevices devices, Guid interfaceGuid) { foreach (IUPnPDevice ldDevice in devices) { this.Add(new Device(ldDevice, interfaceGuid)); } }
/// <summary> /// Gets all the services for a list of devices. /// </summary> /// <param name="devices">The list of devices to find the services for.</param> /// <param name="serviceType">The type of services to search for.</param> /// <returns>The list of services found.</returns> public static Services FindServices(this IUPnPDevices devices, string serviceType) { Services lsServices = new Services(); foreach (IUPnPDevice ldDevice in devices) { lsServices.AddRange(ldDevice.FindServices(Guid.Empty, serviceType)); } return(lsServices); }
/// <summary> /// Finds services by URI synchronously waiting for the entire search to complete. /// </summary> /// <param name="serviceType">The partial or full service type to search for (cannot be null or empty).</param> /// <returns>A list of services containing the found services.</returns> /// <exception cref="System.ArgumentException">Thrown when serviceType is null or empty.</exception> public static Services FindServices(string serviceType) { if (String.IsNullOrEmpty(serviceType)) { throw new ArgumentException("cannot be null or empty string", "serviceType"); } IUPnPDevices ldDevices = FindNativeDevices(serviceType); return(ldDevices.FindServices(serviceType)); }
/// <summary> /// Finds devices by URI synchronously waiting for the entire search to complete. /// </summary> /// <param name="deviceOrServiceType">The partial or full device or service type to search for (cannot be null or empty).</param> /// <param name="addressFamily">The address family to search in. (Vista or above only).</param> /// <returns>A Devices list containing the found devices.</returns> /// <exception cref="System.ArgumentException">Thrown when deviceOrServiceType is null or empty.</exception> public static Devices FindDevices( string deviceOrServiceType, AddressFamilyFlags addressFamily = AddressFamilyFlags.IPvBoth) { if (String.IsNullOrEmpty(deviceOrServiceType)) { throw new ArgumentException("cannot be null or empty string", "deviceOrServiceType"); } IUPnPDevices ldDevices = FindNativeDevices(deviceOrServiceType, 0); if (ldDevices != null) { return(new Devices(ldDevices, Guid.Empty)); } else { return(null); } }
/// <summary> /// Gets the readable info for a devices list. /// </summary> /// <param name="devices">The list of devices to get the readable info for.</param> /// <param name="indent">The indent for the readable info.</param> /// <returns>The readable info for the devices.</returns> public static string ReadableInfo(this IUPnPDevices devices, int indent = 0) { StringBuilder lsbBuilder = new StringBuilder(); string lsIndent = new String(' ', indent * 4); if (devices.Count > 0) { lsbBuilder.AppendLine(); lsbBuilder.AppendLine(string.Format("{0}{{", lsIndent)); foreach (IUPnPDevice ldDevice in devices) { lsbBuilder.Append(ldDevice.ReadableInfo(indent + 1)); } lsbBuilder.AppendLine(string.Format("{0}}}", lsIndent)); return(lsbBuilder.ToString()); } else { return("(none)" + Environment.NewLine); } }