コード例 #1
0
        /// <summary>
        /// The actual factory method which returns the correct implementation of the image converter
        /// based on the first bytes in the input stream.
        /// </summary>
        /// <param name="stream">The input stream</param>
        /// <returns>Interface abstracting the different implementations of the image converter</returns>
        public static IImageConverter GetImageConverter(Stream stream)
        {
            IImageConverter result = null;

            var pngImageConverter = new PngImageConverter(stream);
            if (pngImageConverter.IsSupportedFormat())
            {
                result = pngImageConverter;
            }

            var gifImageConverter = new GifImageConverter(stream);
            if (gifImageConverter.IsSupportedFormat())
            {
                result = gifImageConverter;
            }

            return result;
        }
コード例 #2
0
        /// <summary>
        /// The actual factory method which returns the correct implementation of the image converter
        /// based on the first bytes in the input stream.
        /// </summary>
        /// <param name="stream">The input stream</param>
        /// <returns>Interface abstracting the different implementations of the image converter</returns>
        public static IImageConverter GetImageConverter(Stream stream)
        {
            IImageConverter result = null;

            var pngImageConverter = new PngImageConverter(stream);

            if (pngImageConverter.IsSupportedFormat())
            {
                result = pngImageConverter;
            }

            var gifImageConverter = new GifImageConverter(stream);

            if (gifImageConverter.IsSupportedFormat())
            {
                result = gifImageConverter;
            }

            return(result);
        }