HttpLanguageRangeWithQualityHeaderValueCollection Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Rappresenta il valore dell'intestazione HTTP Accept-Language in una richiesta HTTP.
public ref class HttpLanguageRangeWithQualityHeaderValueCollection sealed : IIterable<HttpLanguageRangeWithQualityHeaderValue ^>, IVector<HttpLanguageRangeWithQualityHeaderValue ^>, 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 HttpLanguageRangeWithQualityHeaderValueCollection final : IIterable<HttpLanguageRangeWithQualityHeaderValue>, IVector<HttpLanguageRangeWithQualityHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpLanguageRangeWithQualityHeaderValueCollection final : IIterable<HttpLanguageRangeWithQualityHeaderValue>, IVector<HttpLanguageRangeWithQualityHeaderValue>, 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 HttpLanguageRangeWithQualityHeaderValueCollection : IEnumerable<HttpLanguageRangeWithQualityHeaderValue>, IList<HttpLanguageRangeWithQualityHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpLanguageRangeWithQualityHeaderValueCollection : IEnumerable<HttpLanguageRangeWithQualityHeaderValue>, IList<HttpLanguageRangeWithQualityHeaderValue>, IStringable
Public NotInheritable Class HttpLanguageRangeWithQualityHeaderValueCollection
Implements IEnumerable(Of HttpLanguageRangeWithQualityHeaderValue), IList(Of HttpLanguageRangeWithQualityHeaderValue), IStringable
- Ereditarietà
- 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 Accept-Language in un oggetto HttpRequestMessage usando le proprietà e i metodi nelle classi HttpLanguageRangeWithQualityHeaderValueCollection e HttpLanguageRangeWithQualityHeaderValue .
using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;
public void DemonstrateHeaderRequestAcceptLanguage() {
var request = new HttpRequestMessage();
bool parsedOk = false;
// Set the header with a string.
parsedOk = request.Headers.AcceptLanguage.TryParseAdd("da");
parsedOk = request.Headers.AcceptLanguage.TryParseAdd("en-gb;q=0.8");
// Set the header with a strong type.
request.Headers.AcceptLanguage.Add(new HttpLanguageRangeWithQualityHeaderValue("en", .7));
// Get the strong type out
foreach (var value in request.Headers.AcceptLanguage) {
System.Diagnostics.Debug.WriteLine("One of the AcceptLanguage values: {0}={1}", value.LanguageRange, value.Quality);
}
// The ToString() is useful for diagnostics, too.
System.Diagnostics.Debug.WriteLine("The AcceptLanguage ToString() results: {0}", request.Headers.AcceptLanguage.ToString());
}
Commenti
La classe HttpLanguageRangeWithQualityHeaderValueCollection rappresenta il valore dell'intestazione HTTP Accept-Language in una richiesta HTTP.
HttpLanguageRangeWithQualityHeaderValueCollection fornisce un contenitore di raccolta per le istanze della classe HttpLanguageRangeWithQualityHeaderValue utilizzata per accettare informazioni sulla lingua nell'intestazione HTTP Accept-Language .
La proprietà AcceptLanguage in HttpRequestHeaderCollection restituisce un oggetto HttpLanguageRangeWithQualityHeaderValueCollection.
Proprietà
Size |
Ottiene il numero di oggetti HttpLanguageRangeWithQualityHeaderValue nell'insieme. |