public void SetOutput(Stream stream, Encoding encoding, bool ownsStream)
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
if (encoding == null)
throw new ArgumentNullException(nameof(encoding));
if (encoding.WebName != Encoding.UTF8.WebName)
{
stream = new EncodingStreamWrapper(stream, encoding, true);
}
if (_writer == null)
{
_writer = new XmlUTF8NodeWriter();
}
_writer.SetOutput(stream, ownsStream, encoding);
SetOutput(_writer);
}
}