/// <summary> /// Gets the service description for a native device and service. /// </summary> /// <param name="device">The native device.</param> /// <param name="service">The native service.</param> /// <returns>The service description for the cache or null if not available.</returns> internal ServiceDescription this[IUPnPDevice device, IUPnPService service] { get { ServiceDescription lsdDesc; string lsKey = KeyFor(device, service); if (Logging.Enabled) { Logging.Log(this, string.Format("Getting ServiceDescription from cache for: '{0}' root of '{1}' key '{2}'", device.RootDevice.FriendlyName, service.Id, lsKey), 1); } try { if (!mdCache.TryGetValue(lsKey, out lsdDesc)) { if (Logging.Enabled) { Logging.Log(this, "Cache missed"); } lsdDesc = service.Description(device, RootDescriptionCache.Cache[device.RootDevice]); if (lsdDesc != null) { if (Logging.Enabled) { Logging.Log(this, "Adding to cache"); } mdCache[lsKey] = lsdDesc; mdURLCache[lsdDesc.DocumentURL] = lsdDesc; } else if (Logging.Enabled) { Logging.Log(this, "Failed, nothing to add to cache"); } } return(lsdDesc); } finally { if (Logging.Enabled) { Logging.Log(this, "Finished getting ServiceDescription from cache", -1); } } } }
/// <summary> /// Gets the service description for a native device and service. /// </summary> /// <param name="device">The native device.</param> /// <param name="service">The native service.</param> /// <returns>The service description for the cache or null if not available.</returns> internal ServiceDescription this[IUPnPDevice device, IUPnPService service] { get { ServiceDescription lsdDesc; string lsKey = KeyFor(device, service); if (Logging.Enabled) Logging.Log(this, string.Format("Getting ServiceDescription from cache for: '{0}' root of '{1}' key '{2}'", device.RootDevice.FriendlyName, service.Id, lsKey), 1); try { if (!mdCache.TryGetValue(lsKey, out lsdDesc)) { if (Logging.Enabled) Logging.Log(this, "Cache missed"); lsdDesc = service.Description(device, RootDescriptionCache.Cache[device.RootDevice]); if (lsdDesc != null) { if (Logging.Enabled) Logging.Log(this, "Adding to cache"); mdCache[lsKey] = lsdDesc; mdURLCache[lsdDesc.DocumentURL] = lsdDesc; } else if (Logging.Enabled) Logging.Log(this, "Failed, nothing to add to cache"); } return lsdDesc; } finally { if (Logging.Enabled) Logging.Log(this, "Finished getting ServiceDescription from cache", -1); } } }