Esempio n. 1
0
        /// <summary>
        /// Gets the image cache tag.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="imageType">Type of the image.</param>
        /// <param name="imagePath">The image path.</param>
        /// <returns>Guid.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        public Guid GetImageCacheTag(BaseItem item, ImageType imageType, string imagePath)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (string.IsNullOrEmpty(imagePath))
            {
                throw new ArgumentNullException("imagePath");
            }

            var dateModified = GetImageDateModified(item, imagePath);

            var supportedEnhancers = ImageEnhancers.Where(i =>
            {
                try
                {
                    return(i.Supports(item, imageType));
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);

                    return(false);
                }
            }).ToList();

            return(GetImageCacheTag(imagePath, dateModified, supportedEnhancers, item, imageType));
        }
        public IEnumerable <IImageEnhancer> GetSupportedEnhancers(IHasImages item, ImageType imageType)
        {
            return(ImageEnhancers.Where(i =>
            {
                try
                {
                    return i.Supports(item, imageType);
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);

                    return false;
                }
            }));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the enhanced image.
        /// </summary>
        /// <param name="originalImagePath">The original image path.</param>
        /// <param name="dateModified">The date modified.</param>
        /// <param name="item">The item.</param>
        /// <param name="imageType">Type of the image.</param>
        /// <param name="imageIndex">Index of the image.</param>
        /// <returns>Task{System.String}.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        public Task <string> GetEnhancedImage(string originalImagePath, DateTime dateModified, BaseItem item, ImageType imageType, int imageIndex)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var supportedImageEnhancers = ImageEnhancers.Where(i =>
            {
                try
                {
                    return(i.Supports(item, imageType));
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name);

                    return(false);
                }
            }).ToList();

            return(GetEnhancedImage(originalImagePath, dateModified, item, imageType, imageIndex, supportedImageEnhancers));
        }