Bagikan melalui


BodyWriter.CreateBufferedCopy(Int32) Metode

Definisi

Membuat salinan isi yang di-buffer.

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

Parameter

maxBufferSize
Int32

Ukuran maksimum buffer untuk isi.

Mengembalikan

Yang BodyWriter berisi salinan objek ini.

Pengecualian

kurang maxBufferSize dari nol.

Isi sudah ditulis dan tidak dapat ditulis lagi, atau body writer tidak di-buffer.

Contoh

Contoh berikut menunjukkan cara membuat salinan buffer instans yang ada 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)

Keterangan

Jika IsBuffered adalah true maka BodyWriter objek dikembalikan. Jika IsBuffered isinya adalah false isi dari BodyWriter hingga maxBufferSize dikembalikan. Ini juga disebut OnCreateBufferedCopy(Int32) sebagai titik ekstensibilitas.

Berlaku untuk