Esempio n. 1
0
        private void CheckMemoryStatus(InputWorkItem inputWorkItem)
        {
            OutputStream         outputStream         = inputWorkItem.OutputStream;
            DecompressorSettings decompressorSettings = (DecompressorSettings)inputWorkItem.Settings;

            if (outputStream.Stream is FileStream)
            {
                return;
            }
            if (MemoryStatus.Current.MemoryLoad < 80)
            {
                return;
            }

            lock (_lockObject)
            {
                if (MemoryStatus.Current.MemoryLoad > decompressorSettings.MemoryLoadThreshold)
                {
                    TempFileStream tempFileStream = new TempFileStream();

                    outputStream.Stream.Position = 0;
                    outputStream.Stream.CopyTo(tempFileStream);

                    outputStream.Stream = tempFileStream;
                }
            }
        }
Esempio n. 2
0
        public Decompressor(DecompressorSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("Settings must be non-empty");
            }

            _settings = settings;
        }
Esempio n. 3
0
        protected override long CalculateRequiredForCompressionStreamMemorySize(IEnumerable <InputStream> inputStreams, FileInfo inputFileInfo)
        {
            DecompressorSettings decompressorSettings = CompressionSettings as DecompressorSettings;

            if (decompressorSettings == null)
            {
                throw new ArgumentException("Settings must be an instance of DecompressorSettings");
            }

            return
                (base.CalculateRequiredForCompressionStreamMemorySize(inputStreams, inputFileInfo) *
                 decompressorSettings.DecompressionFactor);
        }