Compartir a través de


BodyWriter.CreateBufferedCopy(Int32) Método

Definición

Crea una copia del cuerpo almacenada en búfer.

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

El tamaño máximo del búfer para el cuerpo.

Devoluciones

BodyWriter que contiene una copia de este objeto.

Excepciones

maxBufferSize es menor que cero.

El cuerpo se ha escrito y no se puede escribir de nuevo, si no o el sistema de escritura del cuerpo no se almacenará en búfer.

Ejemplos

El ejemplo siguiente muestra cómo crear una copia almacenada en búfer de una instancia BodyWriter existente.

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)

Comentarios

Si IsBuffered es true, se devuelve el objeto BodyWriter. Si IsBuffered es false, se devuelve el contenido de BodyWriter hasta maxBufferSize. Esto también llama a OnCreateBufferedCopy(Int32) como punto de extensibilidad.

Se aplica a