Example #1
0
        public static ZipManager CreateZipManager(Enums.CompressionMode compressionMode, string inputFileName, string outputFileName)
        {
            if (!Enum.IsDefined(typeof(Enums.CompressionMode), compressionMode))
            {
                throw new InvalidEnumArgumentException(nameof(compressionMode), (int)compressionMode,
                                                       typeof(Enums.CompressionMode));
            }
            if (string.IsNullOrEmpty(inputFileName))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(inputFileName));
            }
            if (string.IsNullOrEmpty(outputFileName))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(outputFileName));
            }
            if (string.IsNullOrWhiteSpace(inputFileName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(inputFileName));
            }
            if (string.IsNullOrWhiteSpace(outputFileName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(outputFileName));
            }

            switch (compressionMode)
            {
            case Enums.CompressionMode.Compress:
                return(CreateCompressZipManager(inputFileName, outputFileName));

            case Enums.CompressionMode.Decompress:
                return(CreateDecompressZipManager(inputFileName, outputFileName));

            default: return(null);
            }
        }
Example #2
0
        private void GetDataFromArray(string[] args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            try
            {
                CompressionMode = args[0].ToEnum(Enums.CompressionMode.None);
                InputFileName   = args[1];
                OutputFileName  = args[2];
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine(InfoMessage);
            }
        }