BodyWriter.CreateBufferedCopy(Int32) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Crée une copie mise en mémoire tampon du corps.
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
Paramètres
- maxBufferSize
- Int32
Taille maximale de la mémoire tampon pour le corps.
Retours
BodyWriter qui contient une copie de cet objet.
Exceptions
maxBufferSize
est inférieure à zéro.
Le corps a déjà été écrit et ne peut plus être écrit ou l'enregistreur de corps n'est pas mis en mémoire tampon.
Exemples
L'exemple suivant indique comment créer une copie mise en mémoire tampon d'une instance BodyWriter existante.
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)
Remarques
Si l'objet IsBuffered a la valeur true
alors l'objet BodyWriter est retourné. Si IsBuffered a la valeur false
alors le contenu de BodyWriter jusqu'à maxBufferSize
est retourné. Cela appelle également OnCreateBufferedCopy(Int32) en tant que point d'extensibilité.
S’applique à
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour