BodyWriter.CreateBufferedCopy(Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建正文的缓冲副本。
public:
System::ServiceModel::Channels::BodyWriter ^ CreateBufferedCopy(int maxBufferSize);
public System.ServiceModel.Channels.BodyWriter CreateBufferedCopy (int maxBufferSize);
member this.CreateBufferedCopy : int -> System.ServiceModel.Channels.BodyWriter
Public Function CreateBufferedCopy (maxBufferSize As Integer) As BodyWriter
参数
- maxBufferSize
- Int32
正文缓冲区的最大大小。
返回
一个 BodyWriter,包含此对象的副本。
例外
maxBufferSize
小于零。
已写入正文且无法再次写入,或者未缓冲正文编写器。
示例
下面的示例演示如何创建现有 BodyWriter 实例的缓冲副本。
string[] strings = { "Hello", "world" };
MyBodyWriter bodyWriter = new MyBodyWriter(strings);
StringBuilder strBuilder = new StringBuilder(10);
XmlWriter writer = XmlWriter.Create(strBuilder);
XmlDictionaryWriter dictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer);
bodyWriter.WriteBodyContents(dictionaryWriter);
dictionaryWriter.Flush();
MyBodyWriter bufferedBodyWriter = (MyBodyWriter) bodyWriter.CreateBufferedCopy(1024);
Dim strings() As String = {"Hello", "world"}
Dim bodyWriter As New MyBodyWriter(strings)
Dim strBuilder As New StringBuilder(10)
Dim writer As XmlWriter = XmlWriter.Create(strBuilder)
Dim dictionaryWriter As XmlDictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer)
bodyWriter.WriteBodyContents(dictionaryWriter)
dictionaryWriter.Flush()
Dim bufferedBodyWriter As MyBodyWriter = CType(bodyWriter.CreateBufferedCopy(1024), MyBodyWriter)
注解
如果 IsBuffered 为 true
,则返回 BodyWriter 对象。 如果 IsBuffered 为 false
,则返回 BodyWriter 的最大大小为 maxBufferSize
的内容。 还将调用 OnCreateBufferedCopy(Int32) 作为可扩展点。