Unosquare
    Show / Hide Table of Contents

    Class QValueList

    Represents a list of names with associated quality values extracted from an HTTP header, e.g. gzip; q=0.9, deflate.

    See RFC7231, section 5.3.

    This class ignores and discards extensions (accept-ext in RFC7231 terminology).

    If a name has one or more parameters (e.g. text/html;level=1) it is not further parsed: parameters will appear as part of the name.

    Inheritance
    Object
    QValueList
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: EmbedIO.Utilities
    Syntax
    public sealed class QValueList

    Constructors

    QValueList(Boolean, IEnumerable<String>)

    Initializes a new instance of the QValueList class by parsing comma-separated request header values.

    Declaration
    public QValueList(bool useWildcard, IEnumerable<string> headerValues)
    Parameters
    Type Name Description
    Boolean useWildcard

    If set to true, a value of * will be treated as signifying "anything".

    IEnumerable<String> headerValues

    An enumeration of header values. Note that each element of the enumeration may in turn be a comma-separated list.

    See Also
    UseWildcard

    QValueList(Boolean, String)

    Initializes a new instance of the QValueList class by parsing comma-separated request header values.

    Declaration
    public QValueList(bool useWildcard, string headerValues)
    Parameters
    Type Name Description
    Boolean useWildcard

    If set to true, a value of * will be treated as signifying "anything".

    String headerValues

    A list of comma-separated header values.

    See Also
    UseWildcard

    QValueList(Boolean, String[])

    Initializes a new instance of the QValueList class by parsing comma-separated request header values.

    Declaration
    public QValueList(bool useWildcard, params string[] headerValues)
    Parameters
    Type Name Description
    Boolean useWildcard

    If set to true, a value of * will be treated as signifying "anything".

    String[] headerValues

    An array of header values. Note that each element of the array may in turn be a comma-separated list.

    See Also
    UseWildcard

    Fields

    Wildcard

    A value signifying "anything will do" in request headers.

    For example, a request header of Accept-Encoding: *;q=0.8, gzip means "I prefer GZip compression; if it is not available, any other compression (including no compression at all) is OK for me".

    Declaration
    public const string Wildcard = "*"
    Field Value
    Type Description
    String

    Properties

    QValues

    Gets a dictionary associating values with their relative weight (an integer ranging from 0 to 1000) and their position in the list of header values from which this instance has been constructed.

    Declaration
    public IReadOnlyDictionary<string, (int Weight, int Ordinal)> QValues { get; }
    Property Value
    Type Description
    IReadOnlyDictionary<String, ValueTuple<Int32, Int32>>
    Remarks

    This property does not usually need to be used directly; use the IsCandidate(String), FindPreferred(IEnumerable<String>), FindPreferredIndex(IEnumerable<String>), and FindPreferredIndex(String[]) methods instead.

    See Also
    IsCandidate(String)
    FindPreferred(IEnumerable<String>)
    FindPreferredIndex(IEnumerable<String>)
    FindPreferredIndex(String[])

    UseWildcard

    Gets a value indicating whether * is treated as a special value with the meaning of "anything".

    Declaration
    public bool UseWildcard { get; }
    Property Value
    Type Description
    Boolean

    Methods

    FindPreferred(IEnumerable<String>)

    Finds the value preferred by the client among an enumeration of values.

    Declaration
    public string FindPreferred(IEnumerable<string> values)
    Parameters
    Type Name Description
    IEnumerable<String> values

    The values.

    Returns
    Type Description
    String

    The value preferred by the client, or null if none of the provided values is accepted.

    FindPreferredIndex(IEnumerable<String>)

    Finds the index of the value preferred by the client in a list of values.

    Declaration
    public int FindPreferredIndex(IEnumerable<string> values)
    Parameters
    Type Name Description
    IEnumerable<String> values

    The values.

    Returns
    Type Description
    Int32

    The index of the value preferred by the client, or -1 if none of the values in values is accepted.

    FindPreferredIndex(String[])

    Finds the index of the value preferred by the client in an array of values.

    Declaration
    public int FindPreferredIndex(params string[] values)
    Parameters
    Type Name Description
    String[] values

    The values.

    Returns
    Type Description
    Int32

    The index of the value preferred by the client, or -1 if none of the values in values is accepted.

    IsCandidate(String)

    Determines whether the specified value is a possible candidate.

    Declaration
    public bool IsCandidate(string value)
    Parameters
    Type Name Description
    String value

    The value.

    Returns
    Type Description
    Boolean

    trueif value is a candidate; otherwise, false.

    TryGetWeight(String, out Int32)

    Attempts to determine whether the weight of a possible candidate.

    Declaration
    public bool TryGetWeight(string value, out int weight)
    Parameters
    Type Name Description
    String value

    The value whose weight is to be determined.

    Int32 weight

    When this method returns true, the weight of the candidate.

    Returns
    Type Description
    Boolean

    true if value is a candidate; otherwise, false.

    Comments

    Back to top Copyright © 2017-2019 Unosquare