Partilhar via


BodyWriter.CreateBufferedCopy(Int32) Método

Definição

Cria uma cópia em buffer 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.

Retornos

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

Exceções

O maxBufferSize é menor que zero.

O corpo já foi gravado e não pode ser gravado novamente ou o gravador de corpo não é armazenada em buffer.

Exemplos

O exemplo a seguir 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)

Comentários

Se IsBuffered for true , o BodyWriter objeto será retornado. Se IsBuffered for false , o conteúdo do BodyWriter até maxBufferSize será retornado. Isso também chama OnCreateBufferedCopy(Int32) como um ponto de extensibilidade.

Aplica-se a