Condividi tramite


BodyWriter.CreateBufferedCopy(Int32) Metodo

Definizione

Crea una copia memorizzata nel buffer del corpo.

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

Parametri

maxBufferSize
Int32

Dimensione massima del buffer per il corpo.

Restituisce

Oggetto BodyWriter contenente una copia di questo oggetto.

Eccezioni

è maxBufferSize minore di zero.

Il corpo è già stato scritto e non può essere scritto di nuovo oppure il writer del corpo non viene memorizzato nel buffer.

Esempio

L'esempio seguente illustra come creare una copia memorizzata nel buffer di un'istanza esistente 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)

Commenti

Se IsBuffered è true , viene restituito l'oggetto BodyWriter . Se IsBuffered è false quindi il contenuto dell'oggetto BodyWriter fino a maxBufferSize viene restituito. Viene chiamato OnCreateBufferedCopy(Int32) anche come punto di estendibilità.

Si applica a