示例#1
0
        private static void StartProgram(string[] args)
        {
            var consoleManager = args?.Length == 0 ? new ConsoleManager() : new ConsoleManager(args);

            var zipManager = ManagerFactry.CreateZipManager(consoleManager.CompressionMode, consoleManager.InputFileName, consoleManager.OutputFileName);

            zipManager.Run();

            Console.WriteLine("File was seccessfully {0}ed, enter any button to exit", consoleManager.CompressionMode.ToString().ToLower());
            Console.ReadLine();
        }
示例#2
0
        protected ZipManager(CompressionMode compressionMode, string inputFileName, string outputFileName)
        {
            if (!Enum.IsDefined(typeof(CompressionMode), compressionMode))
            {
                throw new InvalidEnumArgumentException(nameof(compressionMode), (int)compressionMode,
                                                       typeof(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));
            }

            BlockProcessingLength = Convert.ToInt64(ConfigurationManager.AppSettings["blockProcessingLength"]);

            var inputFileInfo = new FileInfo(inputFileName);

            _blocksCount = (inputFileInfo.Length + BlockProcessingLength - 1) / BlockProcessingLength;

            _fileManager = ManagerFactry.CreateFileManager(compressionMode, inputFileName, outputFileName, BlockProcessingLength, inputFileInfo.Length,
                                                           ReadedQueue, OutputQueue);

            if (_fileManager == null)
            {
                throw new InvalidOperationException("Compression mode is invalid");
            }
        }