HttpLanguageRangeWithQualityHeaderValueCollection Classe
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Representa o valor do cabeçalho HTTP Accept-Language em uma solicitação 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
- Herança
- Atributos
- Implementações
Requisitos do Windows
Família de dispositivos |
Windows 10 (introduzida na 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduzida na v1.0)
|
Exemplos
O código de exemplo a seguir mostra um método para obter e definir o cabeçalho HTTP Accept-Language em um objeto HttpRequestMessage usando as propriedades e métodos nas classes 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());
}
Comentários
A classe HttpLanguageRangeWithQualityHeaderValueCollection representa o valor do cabeçalho HTTP Accept-Language em uma solicitação HTTP.
O HttpLanguageRangeWithQualityHeaderValueCollection fornece um contêiner de coleção para instâncias da classe HttpLanguageRangeWithQualityHeaderValue usada para aceitar informações de idioma no cabeçalho HTTP Accept-Language .
A propriedade AcceptLanguage no HttpRequestHeaderCollection retorna um objeto HttpLanguageRangeWithQualityHeaderValueCollection.
Propriedades
Size |
Obtém o número de objetos HttpLanguageRangeWithQualityHeaderValue na coleção. |