Share via


BodyWriter.CreateBufferedCopy(Int32) メソッド

定義

本文のバッファーされたコピーを作成します。

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 が 0 未満です。

本文は既に書き込まれており、再び書き込むことはできません。または、本文ライターがバッファーされていません。

次のサンプルでは、既存の 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)

注釈

IsBufferedtrue である場合は、BodyWriter オブジェクトが返されます。 IsBufferedfalse の場合は、BodyWriter の内容が、最大で maxBufferSize だけ返ります。 このメソッドは、機能拡張ポイントとして OnCreateBufferedCopy(Int32) も呼び出します。

適用対象