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; } } }
public Decompressor(DecompressorSettings settings) { if (settings == null) { throw new ArgumentNullException("Settings must be non-empty"); } _settings = settings; }
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); }