BodyWriter.CreateBufferedCopy(Int32) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
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.