/// <summary>
        /// Gets the remote image.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{System.Object}.</returns>
        private async Task <object> GetRemoteImage(GetRemoteSearchImage request)
        {
            var urlHash          = request.ImageUrl.GetMD5();
            var pointerCachePath = GetFullCachePath(urlHash.ToString());

            string contentPath;

            try
            {
                contentPath = File.ReadAllText(pointerCachePath);

                if (File.Exists(contentPath))
                {
                    return(await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false));
                }
            }
            catch (FileNotFoundException)
            {
                // Means the file isn't cached yet
            }
            catch (IOException)
            {
                // Means the file isn't cached yet
            }

            await DownloadImage(request.ProviderName, request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);

            // Read the pointer file again
            contentPath = File.ReadAllText(pointerCachePath);

            return(await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false));
        }
        /// <summary>
        /// Gets the remote image.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>Task{System.Object}.</returns>
        private async Task <object> GetRemoteImage(GetRemoteSearchImage request)
        {
            var urlHash          = request.ImageUrl.GetMD5();
            var pointerCachePath = GetFullCachePath(urlHash.ToString());

            string contentPath;

            try
            {
                using (var reader = new StreamReader(pointerCachePath))
                {
                    contentPath = await reader.ReadToEndAsync().ConfigureAwait(false);
                }

                if (File.Exists(contentPath))
                {
                    return(ToStaticFileResult(contentPath));
                }
            }
            catch (DirectoryNotFoundException)
            {
                // Means the file isn't cached yet
            }
            catch (FileNotFoundException)
            {
                // Means the file isn't cached yet
            }

            await DownloadImage(request.ProviderName, request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false);

            // Read the pointer file again
            using (var reader = new StreamReader(pointerCachePath))
            {
                contentPath = await reader.ReadToEndAsync().ConfigureAwait(false);
            }

            return(ToStaticFileResult(contentPath));
        }
 public Task <object> Get(GetRemoteSearchImage request)
 {
     return(GetRemoteImage(request));
 }
        public object Get(GetRemoteSearchImage request)
        {
            var result = GetRemoteImage(request).Result;

            return(result);
        }