BodyWriter.CreateBufferedCopy(Int32) Método

Definição

Cria uma cópia bufferizada do 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

Parâmetros

maxBufferSize
Int32

O tamanho máximo do buffer para o corpo.

Devoluções

A BodyWriter que contém uma cópia deste objeto.

Exceções

O maxBufferSize é inferior a zero.

O corpo já foi escrito e não pode ser escrito novamente, ou o escritor corporal não está em buffer.

Exemplos

O exemplo seguinte mostra como criar uma cópia em buffer de uma instância existente 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)

Observações

Se IsBuffered for true então o BodyWriter objeto é devolvido. Se IsBuffered for false então o conteúdo do BodyWriter até maxBufferSize é devolvido. Isto também chama OnCreateBufferedCopy(Int32) um ponto de extensibilidade.

Aplica-se a