/// <summary>
 /// Gets the cache key.
 /// </summary>
 protected override Tuple <ICacheKey, int> GetKey(
     IProducerContext producerContext)
 {
     return(new Tuple <ICacheKey, int>(
                _cacheKeyFactory.GetBitmapCacheKey(
                    producerContext.ImageRequest,
                    producerContext.CallerContext),
                producerContext.LowestPermittedRequestLevel));
 }
        /// <summary>
        /// Returns whether the image is stored in the bitmap memory cache.
        /// </summary>
        /// <param name="imageRequest">
        /// The imageRequest for the image to be looked up.
        /// </param>
        /// <returns>
        /// true if the image was found in the bitmap memory cache,
        /// false otherwise.
        /// </returns>
        public bool IsInBitmapMemoryCache(ImageRequest imageRequest)
        {
            if (imageRequest == null)
            {
                return(false);
            }

            ICacheKey cacheKey = _cacheKeyFactory.GetBitmapCacheKey(imageRequest, null);
            CloseableReference <CloseableImage> reference = _bitmapMemoryCache.Get(cacheKey);

            try
            {
                return(CloseableReference <CloseableImage> .IsValid(reference));
            }
            finally
            {
                CloseableReference <CloseableImage> .CloseSafely(reference);
            }
        }