/// <summary> /// Instantiate a new LZ4 codec handler. /// </summary> /// <param name="blockSize">Block size to compress against.</param> /// <param name="highCompression">Whether to use high compression mode.</param> /// <param name="memoryStreamManager">RecyclableMemoryStreamManager to allocate buffers from.</param> /// <param name="codecProvider">Which codec provider to use.</param> public LZ4Codec(int blockSize, bool highCompression, RecyclableMemoryStreamManager memoryStreamManager, CodecProvider codecProvider) { if (blockSize < 1 << 12 || blockSize > 1 << 28) { throw new ArgumentOutOfRangeException(nameof(blockSize), "Block size must be between 4KB and 256MB inclusive."); } if (memoryStreamManager == null) { throw new ArgumentNullException(nameof(memoryStreamManager)); } switch (codecProvider) { case CodecProvider.LZ4Net: this.provider = new LZ4NetCodecProvider(); break; default: throw new ArgumentOutOfRangeException(nameof(codecProvider)); } this.BlockSize = blockSize; this.HighCompression = highCompression; this.Codec = codecProvider; this.memoryStreamManager = memoryStreamManager; }
/// <summary> /// Instantiate a new LZ4 codec handler. /// </summary> /// <param name="blockSize">Block size to compress against.</param> /// <param name="highCompression">Whether to use high compression mode.</param> /// <param name="memoryStreamManager">RecyclableMemoryStreamManager to allocate buffers from.</param> /// <param name="codecProvider">Which codec provider to use.</param> public LZ4Codec(int blockSize, bool highCompression, RecyclableMemoryStreamManager memoryStreamManager, CodecProvider codecProvider) { if (blockSize < 1 << 12 || blockSize > 1 << 28) { throw new ArgumentOutOfRangeException(nameof(blockSize), "Block size must be between 4KB and 256MB inclusive."); } if (memoryStreamManager == null) { throw new ArgumentNullException(nameof(memoryStreamManager)); } switch (codecProvider) { case CodecProvider.LZ4Net: this.provider = new LZ4NetCodecProvider(); break; default: throw new ArgumentOutOfRangeException(nameof(codecProvider)); } this.BlockSize = blockSize; this.HighCompression = highCompression; this.Codec = codecProvider; this.memoryStreamManager = memoryStreamManager; }