Beispiel #1
0
 public static bool LoadImage(WebImage image, HttpRequestParameters requestParameters = null, Predicate <ImageMongoCache> filter = null)
 {
     if (image.Url != null && image.Image == null)
     {
         try
         {
             if (_imageCacheManager != null)
             {
                 ImageMongoCache imageCache = (ImageMongoCache)_imageCacheManager.GetImageCache(image.Url, requestParameters);
                 if (filter != null && !filter(imageCache))
                 {
                     return(false);
                 }
                 image.Image = imageCache.Image;
             }
             else
             {
                 image.Image = HttpManager.CurrentHttpManager.LoadImage(new HttpRequest {
                     Url = image.Url
                 }, requestParameters);
             }
         }
         catch (Exception ex)
         {
             Trace.WriteLine("error loading image \"{0}\"", image.Url);
             Trace.WriteLine(ex.Message);
             //return false;
         }
     }
     return(true);
 }
Beispiel #2
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);
 }