Esempio n. 1
0
        public Image ProcessImage(Image image, ImageSize size, ImageProportion proportion)
        {
            if (!Sizes.Contains(size))
            {
                throw new ArgumentException($"Parameter `{nameof(size)}` is not supported at the moment!");
            }

            if (!Proportions.Contains(proportion))
            {
                throw new ArgumentException($"Parameter `{nameof(size)}` is not supported at the moment!");
            }

            var formatter = ProportionServiceResolver(proportion);

            if (formatter is null)
            {
                throw new NotSupportedException($"Formatter of `{nameof(proportion)}` is not supported yet!");
            }

            if (size == ImageSize.Origin && proportion == ImageProportion.Origin)
            {
                return(image);
            }

            try
            {
                return(formatter.PrepareImage(ResizeImage, image, size));
            }
            catch (NotSupportedImageSizeException ex)
            {
                Logger.LogError(ex,
                                "An exception ocurred in {0} while processing image for different sizes!",
                                GetFullMemberName());
            }
            return(null);
        }
Esempio n. 2
0
 /// <summary>
 /// Determines whether or not the given length of bytes is valid for a mystery gift.
 /// </summary>
 /// <param name="len">Length, in bytes, of the data of which to determine validity.</param>
 /// <returns>A boolean indicating whether or not the given length is valid for a mystery gift.</returns>
 public static bool IsMysteryGift(long len) => Sizes.Contains((int)len);