HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection HttpMediaTypeWithQualityHeaderValueCollection Class

Definition

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

public : sealed class HttpMediaTypeWithQualityHeaderValueCollection : IIterable<HttpMediaTypeWithQualityHeaderValue>, IVector<HttpMediaTypeWithQualityHeaderValue>, IStringable, IHttpMediaTypeWithQualityHeaderValueCollection
struct winrt::Windows::Web::Http::Headers::HttpMediaTypeWithQualityHeaderValueCollection : IIterable<HttpMediaTypeWithQualityHeaderValue>, IVector<HttpMediaTypeWithQualityHeaderValue>, IStringable, IHttpMediaTypeWithQualityHeaderValueCollection
public sealed class HttpMediaTypeWithQualityHeaderValueCollection : IEnumerable<HttpMediaTypeWithQualityHeaderValue>, IList<HttpMediaTypeWithQualityHeaderValue>, IStringable, IHttpMediaTypeWithQualityHeaderValueCollection
Public NotInheritable Class HttpMediaTypeWithQualityHeaderValueCollection Implements IEnumerable<HttpMediaTypeWithQualityHeaderValue>, IList<HttpMediaTypeWithQualityHeaderValue>, IStringable, IHttpMediaTypeWithQualityHeaderValueCollection
// 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

Item[Int32] Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets or sets the element at the specified index.

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.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through 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(T) IndexOf(T) IndexOf(T) IndexOf(T) IndexOf(T)

Determines the index of a specific item in the System.Collections.Generic.IList`1.

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

Retrieves the index of an HttpMediaTypeWithQualityHeaderValue in the collection.

Insert(Int32, T) Insert(Int32, T) Insert(Int32, T) Insert(Int32, T) Insert(Int32, T)

Inserts an item to the System.Collections.Generic.IList`1 at the specified index.

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(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the System.Collections.Generic.IList`1 item at the specified index.

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