HttpProductInfoHeaderValueCollection Classe

Définition

Représente la valeur de l’en-tête HTTP User-Agent sur une requête HTTP.

public ref class HttpProductInfoHeaderValueCollection sealed : IIterable<HttpProductInfoHeaderValue ^>, IVector<HttpProductInfoHeaderValue ^>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpProductInfoHeaderValueCollection final : IIterable<HttpProductInfoHeaderValue>, IVector<HttpProductInfoHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpProductInfoHeaderValueCollection final : IIterable<HttpProductInfoHeaderValue>, IVector<HttpProductInfoHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpProductInfoHeaderValueCollection : IEnumerable<HttpProductInfoHeaderValue>, IList<HttpProductInfoHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpProductInfoHeaderValueCollection : IEnumerable<HttpProductInfoHeaderValue>, IList<HttpProductInfoHeaderValue>, IStringable
Public NotInheritable Class HttpProductInfoHeaderValueCollection
Implements IEnumerable(Of HttpProductInfoHeaderValue), IList(Of HttpProductInfoHeaderValue), IStringable
Héritage
Object Platform::Object IInspectable HttpProductInfoHeaderValueCollection
Attributs
Implémente

Configuration requise pour Windows

Famille d’appareils
Windows 10 (introduit dans 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v1.0)

Exemples

L’exemple de code suivant montre une méthode permettant d’obtenir et de définir l’en-tête HTTP User-Agent sur un objet HttpRequestMessage à l’aide des propriétés et méthodes des classes HttpProductInfoHeaderValueCollection et HttpProductInfoHeaderValue .

using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderRequestUserAgent() {
            var request = new HttpRequestMessage();
            bool parsedOk = false;

            // Set the header with a string.
            parsedOk = request.Headers.UserAgent.TryParseAdd("testprogram/1.0");

            // Set the header with a strong type.
            request.Headers.UserAgent.Add(new HttpProductInfoHeaderValue("myprogram", "2.2"));

            // Get the strong type out 
            foreach (var value in request.Headers.UserAgent) {
                System.Diagnostics.Debug.WriteLine("One of the UserAgent values: {0} / {1}", value.Product.Name, value.Product.Version);
            }

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The UserAgent ToString() results: {0}", request.Headers.UserAgent.ToString());
        }

Remarques

HttpProductInfoHeaderValueCollection représente la valeur de l’en-tête HTTP User-Agent sur une requête HTTP.

HttpProductInfoHeaderValueCollection est une collection d’objets HttpProductInfoHeaderValue utilisés pour les informations sur le produit dans l’en-tête HTTP User-Agent .

L’en-tête User-Agent contient des informations sur l’agent utilisateur à l’origine de la demande. L’en-tête User-Agent peut contenir plusieurs jetons de produit et commentaires identifiant l’agent utilisateur et tous les sous-produits.

La propriété UserAgent sur httpRequestHeaderCollection renvoie un objet HttpProductInfoHeaderValueCollection.

Propriétés

Size

Obtient le nombre d’objets HttpProductInfoHeaderValue dans la collection.

Méthodes

Append(HttpProductInfoHeaderValue)

Ajoute un nouvel élément HttpProductInfoHeaderValue à la fin de la collection.

Clear()

Supprime tous les objets de la collection.

First()

Récupère un itérateur vers le premier élément HttpProductInfoHeaderValue de la collection.

GetAt(UInt32)

Retourne la valeur HttpProductInfoHeaderValue à l’index spécifié dans la collection.

GetMany(UInt32, HttpProductInfoHeaderValue[])

Récupère les éléments HttpProductInfoHeaderValue qui commencent à l’index spécifié dans la collection.

GetView()

Retourne une vue immuable de l’objet HttpProductInfoHeaderValueCollection.

IndexOf(HttpProductInfoHeaderValue, UInt32)

Récupère l’index d’un objet HttpProductInfoHeaderValue dans la collection.

InsertAt(UInt32, HttpProductInfoHeaderValue)

Insère une valeur HttpProductInfoHeaderValue dans la collection à l’index spécifié.

ParseAdd(String)

Analyse et ajoute une entrée à httpProductInfoHeaderValueCollection.

RemoveAt(UInt32)

Supprime l’entrée à l’index spécifié de l’objet HttpMethodHeaderValueCollection.

RemoveAtEnd()

Supprime le dernier élément HttpProductInfoHeaderValue de la collection.

ReplaceAll(HttpProductInfoHeaderValue[])

Remplace tous les éléments HttpProductInfoHeaderValue de la collection par les éléments HttpProductInfoHeaderValue spécifiés.

SetAt(UInt32, HttpProductInfoHeaderValue)

Définit httpProductInfoHeaderValue à l’index spécifié dans la collection.

ToString()

Renvoie une chaîne qui représente l’objet HttpProductInfoHeaderValueCollection actuel.

TryParseAdd(String)

Tente d’analyser et d’ajouter l’élément spécifié à httpProductInfoHeaderValueCollection.

S’applique à

Voir aussi