Example #1
0
 public GZipService(string fileInput, string fileOutput, IGZipPackager packager, MyCancellationToken cancellationToken)
 {
     _fileInput         = fileInput;
     _fileOutput        = fileOutput;
     _packager          = packager;
     _cancellationToken = cancellationToken;
 }
Example #2
0
        static void Main(string[] args)
        {
            _cancellationToken = new MyCancellationToken();

            Console.CancelKeyPress += new ConsoleCancelEventHandler(CancelKeyPress);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            try
            {
                var command = new Command(args);

                switch (command.Type)
                {
                case CommandTypes.Compress:
                    Console.WriteLine("Compressing...");
                    _iGZipPackager = new GZipCompressor(new BufferStorage <DecompressedData>(_cancellationToken), new BufferStorage <CompressedData>(_cancellationToken));
                    break;

                case CommandTypes.Decompress:
                    Console.WriteLine("Decompressing...");
                    _iGZipPackager = new GZipDecompressor(new BufferStorage <CompressedData>(_cancellationToken), new BufferStorage <DecompressedData>(_cancellationToken));
                    break;

                default:
                    return;
                }

                new GZipService(command.InputFilename, command.OutputFilename, _iGZipPackager, _cancellationToken)
                .Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
                Console.ReadLine();
                return;
            }
        }