/// <summary>
        /// Returns whether the image is stored in the disk cache.
        /// Performs disk cache check synchronously. It is not
        /// recommended to use this unless you know what exactly
        /// you are doing. Disk cache check is a costly operation,
        /// the call will block the caller thread until the cache
        /// check is completed.
        /// </summary>
        /// <param name="uri">
        /// The uri for the image to be looked up.
        /// </param>
        /// <param name="cacheChoice">
        /// The cacheChoice for the cache to be looked up.
        /// </param>
        /// <returns>
        /// true if the image was found in the disk cache,
        /// false otherwise.
        /// </returns>
        public bool IsInDiskCacheSync(Uri uri, CacheChoice cacheChoice)
        {
            ImageRequest imageRequest = ImageRequestBuilder
                                        .NewBuilderWithSource(uri)
                                        .SetCacheChoice(cacheChoice)
                                        .Build();

            return(IsInDiskCacheSync(imageRequest));
        }
        /// <summary>
        /// Custom Equals method.
        /// </summary>
        public override bool Equals(object o)
        {
            if (o.GetType() != typeof(ImageRequest))
            {
                return(false);
            }

            ImageRequest request = (ImageRequest)o;

            return(SourceUri.Equals(request.SourceUri) &&
                   CacheChoice.Equals(request.CacheChoice) &&
                   SourceFile.FullName.Equals(request.SourceFile.FullName));
        }
        /// <summary>
        /// Returns whether the image is stored in the disk cache.
        /// Performs disk cache check synchronously. It is not
        /// recommended to use this unless you know what exactly
        /// you are doing. Disk cache check is a costly operation,
        /// the call will block the caller thread until the cache
        /// check is completed.
        /// </summary>
        /// <param name="imageRequest">
        /// The image request to be looked up.
        /// </param>
        /// <returns>
        /// true if the image was found in the disk cache,
        /// false otherwise.
        /// </returns>
        public bool IsInDiskCacheSync(ImageRequest imageRequest)
        {
            ICacheKey   cacheKey    = _cacheKeyFactory.GetEncodedCacheKey(imageRequest, null);
            CacheChoice cacheChoice = imageRequest.CacheChoice;

            switch (cacheChoice)
            {
            case CacheChoice.DEFAULT:
                return(_mainBufferedDiskCache.DiskCheckSync(cacheKey));

            case CacheChoice.SMALL:
                return(_smallImageBufferedDiskCache.DiskCheckSync(cacheKey));

            default:
                return(false);
            }
        }
 /// <summary>
 /// Sets the cache option.
 /// Pipeline might use different caches and eviction policies for
 /// each image type.
 /// </summary>
 /// <param name="cacheChoice">The cache choice to set.</param>
 /// <returns>The modified builder instance.</returns>
 public ImageRequestBuilder SetCacheChoice(CacheChoice cacheChoice)
 {
     CacheChoice = cacheChoice;
     return(this);
 }