HttpMediaTypeWithQualityHeaderValueCollection 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 ACCEPT HTTP in una richiesta HTTP.
public ref class HttpMediaTypeWithQualityHeaderValueCollection sealed : IIterable<HttpMediaTypeWithQualityHeaderValue ^>, IVector<HttpMediaTypeWithQualityHeaderValue ^>, 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 HttpMediaTypeWithQualityHeaderValueCollection final : IIterable<HttpMediaTypeWithQualityHeaderValue>, IVector<HttpMediaTypeWithQualityHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpMediaTypeWithQualityHeaderValueCollection final : IIterable<HttpMediaTypeWithQualityHeaderValue>, IVector<HttpMediaTypeWithQualityHeaderValue>, 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 HttpMediaTypeWithQualityHeaderValueCollection : IEnumerable<HttpMediaTypeWithQualityHeaderValue>, IList<HttpMediaTypeWithQualityHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpMediaTypeWithQualityHeaderValueCollection : IEnumerable<HttpMediaTypeWithQualityHeaderValue>, IList<HttpMediaTypeWithQualityHeaderValue>, IStringable
Public NotInheritable Class HttpMediaTypeWithQualityHeaderValueCollection
Implements IEnumerable(Of HttpMediaTypeWithQualityHeaderValue), IList(Of HttpMediaTypeWithQualityHeaderValue), 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 Accept HTTP in un oggetto HttpRequestMessage usando le proprietà e i metodi nelle classi HttpMediaTypeWithQualityHeaderValueCollection e HttpMediaTypeWithQualityHeaderValue .
using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;
public void DemonstrateHeaderRequestAccept()
{
var request = new HttpRequestMessage();
bool parsedOk = false;
// Set the header with a string.
parsedOk = request.Headers.Accept.TryParseAdd ("audio/*");
parsedOk = request.Headers.Accept.TryParseAdd ("audio/*; q=0.2");
parsedOk = request.Headers.Accept.TryParseAdd ("audio/*; q=0.4; mysetting=myvalue");
// Set the header with a strong type.
request.Headers.Accept.Add(new HttpMediaTypeWithQualityHeaderValue("audio/*", .6));
// Get the strong type out
foreach (var value in request.Headers.Accept)
{
System.Diagnostics.Debug.WriteLine("One of the Accept values: {0}={1}", value.MediaType, value.Quality);
}
// The ToString() is useful for diagnostics, too.
System.Diagnostics.Debug.WriteLine("The Accept ToString() results: {0}", request.Headers.Accept.ToString());
}
Commenti
HttpMediaTypeWithQualityHeaderValueCollection rappresenta il valore dell'intestazione Accept HTTP in una richiesta HTTP.
HttpMediaTypeWithQualityHeaderValueCollection è un insieme di oggetti HttpMediaTypeWithQualityHeaderValue utilizzati per accettare informazioni nell'intestazione HTTP Accept .
La proprietà Accept in HttpRequestHeaderCollection restituisce un oggetto HttpMediaTypeWithQualityHeaderValueCollection.
Proprietà
Size |
Ottiene il numero di oggetti HttpMediaTypeWithQualityHeaderValue nell'insieme. |