public CStreamReader Convert(Stream stream, Encoding encoding, bool leaveOpen) { if (stream == null || encoding == null) { throw new ArgumentNullException(stream == null ? nameof(stream) : nameof(encoding)); } CStreamReader input = new CStreamReader(stream, encoding, true, 1024, leaveOpen); StringStream ss = new StringStream(1024); CStreamReader result = new CStreamReader(ss, encoding, true, 1024, false); StreamWriter writer = ss.In(); OnConvert(input, writer); writer.Dispose(); input.Dispose(); return(result); }