Пример #1
0
 //Predicate<ImageMongoCache> filter = null
 public bool LoadImage(WebImage webImage, WebImageRequest imageRequest, HttpRequestParameters requestParameters = null)
 {
     //Trace.WriteLine($"WebImageMongo.LoadImage() : \"{webImage.Url}\"    _imageCacheManager {_imageCacheManager}");
     if (webImage.Url != null && webImage.Image == null)
     {
         try
         {
             Image image = null;
             if (_imageCacheManager != null)
             {
                 ImageMongoCache imageCache = (ImageMongoCache)_imageCacheManager.GetImageCache(webImage.Url, requestParameters);
                 //if (_imageFilter != null && !_imageFilter(imageCache))
                 //    return false;
                 image = imageCache.Image;
             }
             else if (imageRequest.LoadImageFromWeb)
                 image = HttpManager.CurrentHttpManager.LoadImage(new HttpRequest { Url = webImage.Url }, requestParameters);
             if (imageRequest.LoadImageToData)
                 webImage.Image = image;
         }
         catch (Exception ex)
         {
             Trace.WriteLine("error loading image \"{0}\"", webImage.Url);
             Trace.WriteLine(ex.Message);
             //return false;
         }
     }
     return true;
 }
Пример #2
0
        //public IEnumerable<WebImage> LoadImages(IEnumerable<WebImage> images, ImageRequest imageRequest, HttpRequestParameters requestParameters = null)
        //{
        //    foreach (WebImage image in images)
        //    {
        //        if (LoadImage(image, imageRequest, requestParameters))
        //            yield return image;
        //    }
        //}

        public void LoadImages(IEnumerable<WebImage> images, WebImageRequest imageRequest, HttpRequestParameters requestParameters = null)
        {
            foreach (WebImage image in images)
            {
                LoadImage(image, imageRequest, requestParameters);
            }
        }