コード例 #1
0
ファイル: ZonePlayer.cs プロジェクト: skavan/Sonority
        void GetDocumentUrl()
        {
            IUPnPDeviceDocumentAccess blah = _device as IUPnPDeviceDocumentAccess;

            if (blah != null)
            {
                _documentUrl = new Uri(blah.GetDocumentURL(), UriKind.Absolute);
                PropertyChanged(this, new PropertyChangedEventArgs("DocumentUrl"));
            }
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
ファイル: UpnpControlPoint.cs プロジェクト: tomaspsenak/hmc
        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);
        }
コード例 #4
0
ファイル: UpnpControlPoint.cs プロジェクト: tomaspsenak/hmc
        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));
            }
        }