HttpProductInfoHeaderValueCollection Classe

Definizione

Rappresenta il valore dell'intestazione HTTP User-Agent in una richiesta 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
Ereditarietà
Object Platform::Object IInspectable HttpProductInfoHeaderValueCollection
Attributi
Implementazioni

Requisiti Windows

Famiglia di dispositivi
Windows 10 (è stato introdotto in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v1.0)

Esempio

Il codice di esempio seguente illustra un metodo per ottenere e impostare l'intestazione HTTP User-Agent in un oggetto HttpRequestMessage usando le proprietà e i metodi nelle classi HttpProductInfoHeaderValueCollection e 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());
        }

Commenti

HttpProductInfoHeaderValueCollection rappresenta il valore dell'intestazione HTTP User-Agent in una richiesta HTTP.

HttpProductInfoHeaderValueCollection è un insieme di oggetti HttpProductInfoHeaderValue utilizzati per le informazioni sul prodotto nell'intestazione HTTP User-Agent .

L'intestazione User-Agent contiene informazioni sull'agente utente che ha origine la richiesta. L'intestazione User-Agent può contenere più token di prodotto e commenti che identificano l'agente utente e tutti i prodotti secondari.

La proprietà UserAgent in HttpRequestHeaderCollection restituisce un oggetto HttpProductInfoHeaderValueCollection.

Proprietà

Size

Ottiene il numero di oggetti HttpProductInfoHeaderValue nell'insieme.

Metodi

Append(HttpProductInfoHeaderValue)

Aggiunge un nuovo elemento HttpProductInfoHeaderValue alla fine della raccolta.

Clear()

Rimuove tutti gli oggetti dalla raccolta.

First()

Recupera un iteratore al primo elemento HttpProductInfoHeaderValue nella raccolta.

GetAt(UInt32)

Restituisce l'oggetto HttpProductInfoHeaderValue in corrispondenza dell'indice specificato nell'insieme.

GetMany(UInt32, HttpProductInfoHeaderValue[])

Recupera gli elementi HttpProductInfoHeaderValue che iniziano in corrispondenza dell'indice specificato nella raccolta.

GetView()

Restituisce una visualizzazione non modificabile di HttpProductInfoHeaderValueCollection.

IndexOf(HttpProductInfoHeaderValue, UInt32)

Recupera l'indice di un oggetto HttpProductInfoHeaderValue nell'insieme.

InsertAt(UInt32, HttpProductInfoHeaderValue)

Inserisce un valore HttpProductInfoHeaderValue nella raccolta in corrispondenza dell'indice specificato.

ParseAdd(String)

Analizza e aggiunge una voce a HttpProductInfoHeaderValueCollection.

RemoveAt(UInt32)

Rimuove la voce in corrispondenza dell'indice specificato da HttpMethodHeaderValueCollection.

RemoveAtEnd()

Rimuove l'ultimo elemento HttpProductInfoHeaderValue dalla raccolta.

ReplaceAll(HttpProductInfoHeaderValue[])

Sostituisce tutti gli elementi HttpProductInfoHeaderValue dell'insieme con gli elementi HttpProductInfoHeaderValue specificati.

SetAt(UInt32, HttpProductInfoHeaderValue)

Imposta HttpProductInfoHeaderValue in corrispondenza dell'indice specificato nell'insieme.

ToString()

Restituisce una stringa che rappresenta l'oggetto HttpProductInfoHeaderValueCollection corrente.

TryParseAdd(String)

Tenta di analizzare e aggiungere l'elemento specificato a HttpProductInfoHeaderValueCollection.

Si applica a

Vedi anche