/// <summary> /// Sets an new memory allocation strategy. Calling this method will resize /// the read buffer if the maximum buffer size has changed. /// </summary> /// <param name="strategy">The new memory allocation strategy.</param> public void SetStrategy(MemoryStrategy strategy) { if (strategy.MaxSize != MemoryStrategy.Unlimited && strategy.MaxSize != this.strategy.MaxSize && strategy.MaxSize < data.buffer.Length) { // Make sure we don't loose data on resize: if (strategy.MaxSize < data.buffer.Length - data.ppos) { strategy.MaxSize = data.buffer.Length - data.ppos; } data.MoveData(); data.Resize(strategy.MaxSize); } this.strategy = strategy; }
/// <summary> /// Constructs an decoder object. /// </summary> /// <param name="stream">The input source stream.</param> /// <param name="strategy">The memory allocation strategy to use.</param> /// <param name="encoding">The character encoding to use.</param> public Decoder(Stream stream, MemoryStrategy strategy, Encoding encoding) { this.strategy = strategy; this.encoding = encoding; this.stream = stream; }
/// <summary> /// Construct an decoder object. /// </summary> /// <param name="stream">The input source stream.</param> /// <param name="encoding">The character encoding to use.</param> public Decoder(Stream stream, Encoding encoding) { this.strategy = new MemoryStrategy(); this.encoding = encoding; this.stream = stream; }
/// <summary> /// Constructs an decoder object. /// </summary> /// <param name="stream">The input source stream.</param> /// <param name="strategy">The memory allocation strategy to use.</param> public Decoder(Stream stream, MemoryStrategy strategy) { this.strategy = strategy; this.stream = stream; }
/// <summary> /// Construct an decoder object. /// </summary> /// <param name="stream">The input source stream.</param> public Decoder(Stream stream) { this.strategy = new MemoryStrategy(); this.stream = stream; }