HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection Class

Definition

Represents the value of the Accept HTTP header on an HTTP request.

public : sealed class HttpMediaTypeWithQualityHeaderValueCollection : IStringable
struct winrt::Windows::Web::Http::Headers::HttpMediaTypeWithQualityHeaderValueCollection : IStringable
public sealed class HttpMediaTypeWithQualityHeaderValueCollection : IStringable
Public NotInheritable Class HttpMediaTypeWithQualityHeaderValueCollection Implements IStringable
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following sample code shows a method to get and set the Accept HTTP header on an HttpRequestMessage object using the properties and methods on the HttpMediaTypeWithQualityHeaderValueCollection and HttpMediaTypeWithQualityHeaderValue classes.

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());
        }

Remarks

The HttpMediaTypeWithQualityHeaderValueCollection represents the value of the Accept HTTP header on an HTTP request.

The HttpMediaTypeWithQualityHeaderValueCollection is a collection of HttpMediaTypeWithQualityHeaderValue objects used for accept information in the HTTP Accept header.

The Accept property on the HttpRequestHeaderCollection returns an HttpMediaTypeWithQualityHeaderValueCollection object.

Properties

Size Size Size Size Size

Gets the number of HttpMediaTypeWithQualityHeaderValue objects in the collection.

Methods

Append(HttpMediaTypeWithQualityHeaderValue) Append(HttpMediaTypeWithQualityHeaderValue) Append(HttpMediaTypeWithQualityHeaderValue) Append(HttpMediaTypeWithQualityHeaderValue) Append(HttpMediaTypeWithQualityHeaderValue)

Adds a new HttpMediaTypeWithQualityHeaderValue item to the end of the collection.

Clear() Clear() Clear() Clear() Clear()

Removes all objects from the collection.

First() First() First() First() First()

Retrieves an iterator to the first HttpMediaTypeWithQualityHeaderValue item in the collection.

GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32) GetAt(UInt32)

Returns the HttpMediaTypeWithQualityHeaderValue at the specified index in the collection.

GetMany(UInt32, HttpMediaTypeWithQualityHeaderValue[]) GetMany(UInt32, HttpMediaTypeWithQualityHeaderValue[]) GetMany(UInt32, HttpMediaTypeWithQualityHeaderValue[]) GetMany(UInt32, HttpMediaTypeWithQualityHeaderValue[]) GetMany(UInt32, HttpMediaTypeWithQualityHeaderValue[])

Retrieves the HttpMediaTypeWithQualityHeaderValue items that start at the specified index in the collection.

GetView() GetView() GetView() GetView() GetView()

Returns an immutable view of the HttpMediaTypeWithQualityHeaderValueCollection.

IndexOf(HttpMediaTypeWithQualityHeaderValue, UInt32) IndexOf(HttpMediaTypeWithQualityHeaderValue, UInt32) IndexOf(HttpMediaTypeWithQualityHeaderValue, UInt32) IndexOf(HttpMediaTypeWithQualityHeaderValue, UInt32) IndexOf(HttpMediaTypeWithQualityHeaderValue, UInt32)

Retrieves the index of an HttpMediaTypeWithQualityHeaderValue in the collection.

InsertAt(UInt32, HttpMediaTypeWithQualityHeaderValue) InsertAt(UInt32, HttpMediaTypeWithQualityHeaderValue) InsertAt(UInt32, HttpMediaTypeWithQualityHeaderValue) InsertAt(UInt32, HttpMediaTypeWithQualityHeaderValue) InsertAt(UInt32, HttpMediaTypeWithQualityHeaderValue)

Inserts an HttpMediaTypeWithQualityHeaderValue into the collection at the specified index.

ParseAdd(String) ParseAdd(String) ParseAdd(String) ParseAdd(String) ParseAdd(String)

Parses and adds an entry to the HttpMediaTypeWithQualityHeaderValueCollection.

RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32) RemoveAt(UInt32)

Removes the entry at the specified index from the HttpMediaTypeWithQualityHeaderValueCollection.

RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd() RemoveAtEnd()

Removes the last HttpMediaTypeWithQualityHeaderValue item from the collection.

ReplaceAll(HttpMediaTypeWithQualityHeaderValue[]) ReplaceAll(HttpMediaTypeWithQualityHeaderValue[]) ReplaceAll(HttpMediaTypeWithQualityHeaderValue[]) ReplaceAll(HttpMediaTypeWithQualityHeaderValue[]) ReplaceAll(HttpMediaTypeWithQualityHeaderValue[])

Replaces all the HttpMediaTypeWithQualityHeaderValue items in the collection with the specified HttpMediaTypeWithQualityHeaderValue items.

SetAt(UInt32, HttpMediaTypeWithQualityHeaderValue) SetAt(UInt32, HttpMediaTypeWithQualityHeaderValue) SetAt(UInt32, HttpMediaTypeWithQualityHeaderValue) SetAt(UInt32, HttpMediaTypeWithQualityHeaderValue) SetAt(UInt32, HttpMediaTypeWithQualityHeaderValue)

Sets the HttpMediaTypeWithQualityHeaderValue at the specified index in the collection.

ToString() ToString() ToString() ToString() ToString()

Returns a string that represents the current HttpMediaTypeWithQualityHeaderValueCollection object.

TryParseAdd(String) TryParseAdd(String) TryParseAdd(String) TryParseAdd(String) TryParseAdd(String)

Tries to parse and add the specified item to the HttpMediaTypeWithQualityHeaderValueCollection.

See also