未验证 提交 ad17b93b 编写于 作者: S Steve Molloy 提交者: GitHub

Implement IXmlTextWriterInitializer on the async writer wrapper. (#73730)

* Implement IXmlTextWriterInitializer on the async writer wrapper.

* Don't use generics per PR feedback.

* Use cast in SetOutput instead of typed field.
上级 d3a803c8
......@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
......@@ -11,13 +12,14 @@
namespace System.Xml
{
internal sealed class XmlDictionaryAsyncCheckWriter : XmlDictionaryWriter
internal sealed class XmlDictionaryAsyncCheckWriter : XmlDictionaryWriter, IXmlTextWriterInitializer
{
private readonly XmlDictionaryWriter _coreWriter;
private Task? _lastTask;
public XmlDictionaryAsyncCheckWriter(XmlDictionaryWriter writer)
{
Debug.Assert(writer is IXmlTextWriterInitializer);
_coreWriter = writer;
}
......@@ -694,5 +696,14 @@ protected override void Dispose(bool disposing)
CheckAsync();
CoreWriter.Dispose();
}
public void SetOutput(Stream stream, Encoding encoding, bool ownsStream)
{
if (CoreWriter is IXmlTextWriterInitializer initializer)
{
CheckAsync();
initializer.SetOutput(stream, encoding, ownsStream);
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册