void GetDocumentUrl() { IUPnPDeviceDocumentAccess blah = _device as IUPnPDeviceDocumentAccess; if (blah != null) { _documentUrl = new Uri(blah.GetDocumentURL(), UriKind.Absolute); PropertyChanged(this, new PropertyChangedEventArgs("DocumentUrl")); } }
/// <summary> /// Retrieves the local IP addresses of the UPnP-device. /// </summary> /// <param name="device">The UPnP device the method is being called for.</param> /// <returns>An enumerable collection of local IP addresses under which /// the UPnP-device can be reached.</returns> /// <remarks>This is an extension method for the IUPnPDeviceDocumentAccess /// class.</remarks> static IEnumerable <IPAddress> GetLocalIpAddresses( this IUPnPDeviceDocumentAccess device) { try { // Get the devices URL and extract the host component of it. Uri uri = new Uri(device.GetDocumentURL()); return(Dns.GetHostAddresses(uri.Host)); } catch (Exception e) { throw new InvalidOperationException("The local IP addresses could not " + "be obtained.", e); } }
private UPnPService GetService(UPnPDevice device, string serviceType, out IUPnPDeviceDocumentAccess deviceAccess) { foreach (UPnPService service in device.Services) { if (StringComparer.OrdinalIgnoreCase.Compare(service.ServiceTypeIdentifier, serviceType) == 0) { deviceAccess = device as IUPnPDeviceDocumentAccess; return(service); } } deviceAccess = null; return(null); }
private UPnPService GetServiceSync(string deviceId, string serviceType, out IUPnPDeviceDocumentAccess deviceAccess) { lock (this) { UPnPDevice device; if (this.devices.ContainsKey(deviceId)) { device = this.devices[deviceId]; } else { throw new MediaCenterException("Device " + deviceId + " not found"); } return(GetService(device, serviceType, out deviceAccess)); } }