コード例 #1
0
ファイル: GZipTestService.cs プロジェクト: EAValov/GZipTest
        /// <summary>
        /// Common constructor for any type of operation.
        /// </summary>
        /// <param name="parameters"><see cref="GZipTestParameters"/>.</param>
        protected GZipTestService(GZipTestParameters parameters)
        {
            _parameters = parameters;

            _flags = new ManualResetEvent[parameters.ProcessingThreadCount];

            _dataService = new DataBlockQueuesService(parameters.QueueItemsLimit);
        }
コード例 #2
0
ファイル: GZipTestService.cs プロジェクト: EAValov/GZipTest
        /// <summary>
        /// Creating service with valid paramters object.
        /// </summary>
        /// <param name="parameters"><see cref="GZipTestParameters"/>.</param>
        public static GZipTestService Factory(GZipTestParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("Parameters is null.");
            }

            switch (parameters.Operation)
            {
            case GZipTestOperation.Compress:
                return(new CompressionService(parameters));

            case GZipTestOperation.Decompress:
                return(new DecompressionService(parameters));

            default:
                throw new InvalidOperationException($"Operation {parameters.Operation.ToString()} is not supported");
            }
        }
コード例 #3
0
        /// <summary>
        /// Application start point.
        /// </summary>
        /// <param name="args"></param>
        public static int Main(string[] args)
        {
            try
            {
                _logger.Info("Application started with parameters {args}", args);

                Stopwatch stop_watch = new Stopwatch();

                stop_watch.Start();

                var parameters = new GZipTestParameters(args);

                var service = GZipTestService.Factory(parameters);

                service.Run();

                stop_watch.Stop();

                _logger.Info($"Completed at {stop_watch.Elapsed.TotalSeconds} seconds.");

                return(0);
            }
            catch (OutOfMemoryException oom_ex)
            {
                _logger.Error(oom_ex, "Insufficient RAM, close some memory consuming applications and try again");
                return(1);
            }
            catch (IOException io_ex)
            {
                _logger.Error(io_ex, "Disc operation failed, check original file availability, disc space and file paths");
                return(1);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                return(1);
            }
        }
コード例 #4
0
 /// <summary>
 /// <see cref="GZipTestService.GZipTestService(GZipTestParameters)"/>
 /// </summary>
 /// <param name="parameters"><see cref="GZipTestParameters"/></param>
 public DecompressionService(GZipTestParameters parameters) : base(parameters)
 {
 }