130 instantiations of StringWithQualityHeaderValue
Microsoft.Net.Http.Headers (1)
StringWithQualityHeaderValue.cs (1)
204StringWithQualityHeaderValue result = new StringWithQualityHeaderValue();
Microsoft.Net.Http.Headers.Tests (129)
StringWithQualityHeaderValueTest.cs (129)
11var value = new StringWithQualityHeaderValue("token"); 15Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue(null)); 16Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue("")); 17Assert.Throws<FormatException>(() => new StringWithQualityHeaderValue("in valid")); 23var value = new StringWithQualityHeaderValue("token", 0.5); 27Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue(null, 0.1)); 28Assert.Throws<ArgumentException>(() => new StringWithQualityHeaderValue("", 0.1)); 29Assert.Throws<FormatException>(() => new StringWithQualityHeaderValue("in valid", 0.1)); 31Assert.Throws<ArgumentOutOfRangeException>(() => new StringWithQualityHeaderValue("t", 1.1)); 32Assert.Throws<ArgumentOutOfRangeException>(() => new StringWithQualityHeaderValue("t", -0.1)); 38var value = new StringWithQualityHeaderValue("token"); 41value = new StringWithQualityHeaderValue("token", 0.1); 44value = new StringWithQualityHeaderValue("token", 0); 47value = new StringWithQualityHeaderValue("token", 1); 51value = new StringWithQualityHeaderValue("token", 0.56789); 58var value1 = new StringWithQualityHeaderValue("t", 0.123); 59var value2 = new StringWithQualityHeaderValue("t", 0.123); 60var value3 = new StringWithQualityHeaderValue("T", 0.123); 61var value4 = new StringWithQualityHeaderValue("t"); 62var value5 = new StringWithQualityHeaderValue("x", 0.123); 63var value6 = new StringWithQualityHeaderValue("t", 0.5); 64var value7 = new StringWithQualityHeaderValue("t", 0.1234); 65var value8 = new StringWithQualityHeaderValue("T"); 66var value9 = new StringWithQualityHeaderValue("x"); 81var value1 = new StringWithQualityHeaderValue("t", 0.123); 82var value2 = new StringWithQualityHeaderValue("t", 0.123); 83var value3 = new StringWithQualityHeaderValue("T", 0.123); 84var value4 = new StringWithQualityHeaderValue("t"); 85var value5 = new StringWithQualityHeaderValue("x", 0.123); 86var value6 = new StringWithQualityHeaderValue("t", 0.5); 87var value7 = new StringWithQualityHeaderValue("t", 0.1234); 88var value8 = new StringWithQualityHeaderValue("T"); 89var value9 = new StringWithQualityHeaderValue("x"); 106CheckValidParse("text", new StringWithQualityHeaderValue("text")); 107CheckValidParse("text;q=0.5", new StringWithQualityHeaderValue("text", 0.5)); 108CheckValidParse("text ; q = 0.5", new StringWithQualityHeaderValue("text", 0.5)); 109CheckValidParse("\r\n text ; q = 0.5 ", new StringWithQualityHeaderValue("text", 0.5)); 110CheckValidParse(" text ", new StringWithQualityHeaderValue("text")); 111CheckValidParse(" \r\n text \r\n ; \r\n q = 0.123", new StringWithQualityHeaderValue("text", 0.123)); 112CheckValidParse(" text ; q = 0.123 ", new StringWithQualityHeaderValue("text", 0.123)); 113CheckValidParse("text;q=1 ", new StringWithQualityHeaderValue("text", 1)); 114CheckValidParse("*", new StringWithQualityHeaderValue("*")); 115CheckValidParse("*;q=0.7", new StringWithQualityHeaderValue("*", 0.7)); 116CheckValidParse(" t", new StringWithQualityHeaderValue("t")); 117CheckValidParse("t;q=0.", new StringWithQualityHeaderValue("t", 0)); 118CheckValidParse("t;q=1.", new StringWithQualityHeaderValue("t", 1)); 119CheckValidParse("t;q=1.000", new StringWithQualityHeaderValue("t", 1)); 120CheckValidParse("t;q=0.12345678", new StringWithQualityHeaderValue("t", 0.12345678)); 121CheckValidParse("t ; q = 0", new StringWithQualityHeaderValue("t", 0)); 122CheckValidParse("iso-8859-5", new StringWithQualityHeaderValue("iso-8859-5")); 123CheckValidParse("unicode-1-1; q=0.8", new StringWithQualityHeaderValue("unicode-1-1", 0.8)); 167CheckValidTryParse("text", new StringWithQualityHeaderValue("text")); 168CheckValidTryParse("text;q=0.5", new StringWithQualityHeaderValue("text", 0.5)); 169CheckValidTryParse("text ; q = 0.5", new StringWithQualityHeaderValue("text", 0.5)); 170CheckValidTryParse("\r\n text ; q = 0.5 ", new StringWithQualityHeaderValue("text", 0.5)); 171CheckValidTryParse(" text ", new StringWithQualityHeaderValue("text")); 172CheckValidTryParse(" \r\n text \r\n ; \r\n q = 0.123", new StringWithQualityHeaderValue("text", 0.123)); 221new StringWithQualityHeaderValue("text1"), 222new StringWithQualityHeaderValue("text2"), 223new StringWithQualityHeaderValue("textA"), 224new StringWithQualityHeaderValue("textB"), 225new StringWithQualityHeaderValue("text3", 0.5), 226new StringWithQualityHeaderValue("text4", 0.5), 227new StringWithQualityHeaderValue("text5", 0.5), 228new StringWithQualityHeaderValue("text6", 0.05), 229new StringWithQualityHeaderValue("text7"), 230new StringWithQualityHeaderValue("text8", 0.5), 231new StringWithQualityHeaderValue("text9"), 232new StringWithQualityHeaderValue("text10", 0.5), 258new StringWithQualityHeaderValue("text1"), 259new StringWithQualityHeaderValue("text2"), 260new StringWithQualityHeaderValue("textA"), 261new StringWithQualityHeaderValue("textB"), 262new StringWithQualityHeaderValue("text3", 0.5), 263new StringWithQualityHeaderValue("text4", 0.5), 264new StringWithQualityHeaderValue("text5", 0.5), 265new StringWithQualityHeaderValue("text6", 0.05), 266new StringWithQualityHeaderValue("text7"), 267new StringWithQualityHeaderValue("text8", 0.5), 268new StringWithQualityHeaderValue("text9"), 269new StringWithQualityHeaderValue("text10", 0.5), 295new StringWithQualityHeaderValue("text1"), 296new StringWithQualityHeaderValue("text2"), 297new StringWithQualityHeaderValue("textA"), 298new StringWithQualityHeaderValue("textB"), 299new StringWithQualityHeaderValue("text3", 0.5), 300new StringWithQualityHeaderValue("text4", 0.5), 301new StringWithQualityHeaderValue("text5", 0.5), 302new StringWithQualityHeaderValue("text6", 0.05), 303new StringWithQualityHeaderValue("text7"), 304new StringWithQualityHeaderValue("text8", 0.5), 305new StringWithQualityHeaderValue("text9"), 306new StringWithQualityHeaderValue("text10", 0.5), 332new StringWithQualityHeaderValue("text1"), 333new StringWithQualityHeaderValue("text2"), 334new StringWithQualityHeaderValue("textA"), 335new StringWithQualityHeaderValue("textB"), 336new StringWithQualityHeaderValue("text3", 0.5), 337new StringWithQualityHeaderValue("text4", 0.5), 338new StringWithQualityHeaderValue("text5", 0.5), 339new StringWithQualityHeaderValue("text6", 0.05), 340new StringWithQualityHeaderValue("text7"), 341new StringWithQualityHeaderValue("text8", 0.5), 342new StringWithQualityHeaderValue("text9"), 343new StringWithQualityHeaderValue("text10", 0.5), 370new StringWithQualityHeaderValue("text1"), 371new StringWithQualityHeaderValue("1"), 372new StringWithQualityHeaderValue("text2"), 373new StringWithQualityHeaderValue("text3", 0.5), 374new StringWithQualityHeaderValue("text4", 0.5), 375new StringWithQualityHeaderValue("stuff"), 376new StringWithQualityHeaderValue("text5", 0.5), 377new StringWithQualityHeaderValue("text6", 0.05), 378new StringWithQualityHeaderValue("text7"), 379new StringWithQualityHeaderValue("text8", 0.5), 380new StringWithQualityHeaderValue("text9"), 381new StringWithQualityHeaderValue("text10", 0.5), 428new StringWithQualityHeaderValue("text1"), 429new StringWithQualityHeaderValue("1"), 430new StringWithQualityHeaderValue("text2"), 431new StringWithQualityHeaderValue("text3", 0.5), 432new StringWithQualityHeaderValue("text4", 0.5), 433new StringWithQualityHeaderValue("stuff"), 434new StringWithQualityHeaderValue("text5", 0.5), 435new StringWithQualityHeaderValue("text6", 0.05), 436new StringWithQualityHeaderValue("text7"), 437new StringWithQualityHeaderValue("text8", 0.5), 438new StringWithQualityHeaderValue("text9"), 439new StringWithQualityHeaderValue("text10", 0.5),
114 references to StringWithQualityHeaderValue
Microsoft.AspNetCore.Components.WebAssembly.Server (3)
ContentEncodingNegotiator.cs (3)
48if (!StringWithQualityHeaderValue.TryParseList(accept, out var encodings) || encodings.Count == 0) 56foreach (var encoding in encodings) 97StringSegment PickPreferredEncoding(HttpContext context, StringSegment selectedEncoding, StringWithQualityHeaderValue encoding)
Microsoft.AspNetCore.HeaderParsing (6)
CommonHeaders.cs (2)
30public static HeaderSetup<IReadOnlyList<StringWithQualityHeaderValue>> AcceptEncoding => new(HeaderNames.AcceptEncoding, StringWithQualityHeaderValueListParser.Instance, cacheable: true); 35public static HeaderSetup<IReadOnlyList<StringWithQualityHeaderValue>> AcceptLanguage => new(HeaderNames.AcceptLanguage, StringWithQualityHeaderValueListParser.Instance, cacheable: true);
Parsers\StringWithQualityHeaderValueListParser.cs (4)
11internal sealed class StringWithQualityHeaderValueListParser : HeaderParser<IReadOnlyList<StringWithQualityHeaderValue>> 15public override bool TryParse(StringValues values, [NotNullWhen(true)] out IReadOnlyList<StringWithQualityHeaderValue>? result, [NotNullWhen(false)] out string? error) 17if (!StringWithQualityHeaderValue.TryParseList(values, out var parsedValues)) 25result = (IReadOnlyList<StringWithQualityHeaderValue>)parsedValues;
Microsoft.AspNetCore.Http.Extensions (10)
HeaderDictionaryTypeExtensions.cs (4)
156private static IList<StringWithQualityHeaderValue> ParseStringWithQualityHeaderValue(IList<string> value) => 157StringWithQualityHeaderValue.TryParseList(value, out var result) ? result : Array.Empty<StringWithQualityHeaderValue>(); 241else if (typeof(T) == typeof(StringWithQualityHeaderValue))
RequestHeaders.cs (6)
49public IList<StringWithQualityHeaderValue> AcceptCharset 53return Headers.AcceptCharset.GetList<StringWithQualityHeaderValue>(); 64public IList<StringWithQualityHeaderValue> AcceptEncoding 68return Headers.AcceptEncoding.GetList<StringWithQualityHeaderValue>(); 79public IList<StringWithQualityHeaderValue> AcceptLanguage 83return Headers.AcceptLanguage.GetList<StringWithQualityHeaderValue>();
Microsoft.AspNetCore.Http.Extensions.Tests (2)
HeaderDictionaryTypeExtensionsTest.cs (2)
207var result = context.Request.GetTypedHeaders().GetList<StringWithQualityHeaderValue>(HeaderNames.Accept); 209List<StringWithQualityHeaderValue> expected = [new("plain", 0.5), new("html", 0.8)];
Microsoft.AspNetCore.Mvc.Core (9)
Formatters\TextOutputFormatter.cs (9)
170internal static IList<StringWithQualityHeaderValue> GetAcceptCharsetHeaderValues(OutputFormatterWriteContext context) 173if (StringWithQualityHeaderValue.TryParseList(request.Headers.AcceptCharset, out var result)) 178return Array.Empty<StringWithQualityHeaderValue>(); 192private Encoding? MatchAcceptCharacterEncoding(IList<StringWithQualityHeaderValue> acceptCharsetHeaders) 220private static IList<StringWithQualityHeaderValue> Sort(IList<StringWithQualityHeaderValue> values) 226var value = values[i]; 242var sorted = new List<StringWithQualityHeaderValue>(); 245var value = values[i];
Microsoft.AspNetCore.ResponseCompression (2)
ResponseCompressionProvider.cs (2)
88if (!StringWithQualityHeaderValue.TryParseList(accept, out var encodings) || encodings.Count == 0) 96foreach (var encoding in encodings)
Microsoft.AspNetCore.Routing (6)
Matching\NegotiationMatcherPolicy.cs (6)
86!StringWithQualityHeaderValue.TryParseList(header, out var values) || values.Count == 0) 88values = Array.Empty<StringWithQualityHeaderValue>(); 119var value = values[j]; 153StringWithQualityHeaderValue value) 404!StringWithQualityHeaderValue.TryParseList(header, out var values) || values.Count == 0) 417var value = values[i];
Microsoft.Net.Http.Headers (34)
CookieHeaderValue.cs (1)
159/// <returns><see langword="true"/> if all inputs are valid <see cref="StringWithQualityHeaderValue"/>, otherwise <see langword="false"/>.</returns>
NameValueHeaderValue.cs (1)
262/// <returns><see langword="true"/> if all inputs are valid <see cref="StringWithQualityHeaderValue"/>, otherwise <see langword="false"/>.</returns>
SetCookieHeaderValue.cs (1)
466/// <returns><see langword="true"/> if all inputs are valid <see cref="StringWithQualityHeaderValue"/>, otherwise <see langword="false"/>.</returns>
StringWithQualityHeaderValue.cs (26)
16private static readonly HttpHeaderParser<StringWithQualityHeaderValue> SingleValueParser 17= new GenericHeaderParser<StringWithQualityHeaderValue>(false, GetStringWithQualityLength); 18private static readonly HttpHeaderParser<StringWithQualityHeaderValue> MultipleValueParser 19= new GenericHeaderParser<StringWithQualityHeaderValue>(true, GetStringWithQualityLength); 30/// Initializes a new instance of <see cref="StringWithQualityHeaderValue"/>. 41/// Initializes a new instance of <see cref="StringWithQualityHeaderValue"/>. 82var other = obj as StringWithQualityHeaderValue; 121/// Parses the specified <paramref name="input"/> as a <see cref="StringWithQualityHeaderValue"/>. 125public static StringWithQualityHeaderValue Parse(StringSegment input) 132/// Attempts to parse the specified <paramref name="input"/> as a <see cref="StringWithQualityHeaderValue"/>. 136/// <returns><see langword="true"/> if input is a valid <see cref="StringWithQualityHeaderValue"/>, otherwise <see langword="false"/>.</returns> 137public static bool TryParse(StringSegment input, [NotNullWhen(true)] out StringWithQualityHeaderValue? parsedValue) 144/// Parses a sequence of inputs as a sequence of <see cref="StringWithQualityHeaderValue"/> values. 148public static IList<StringWithQualityHeaderValue> ParseList(IList<string>? input) 154/// Parses a sequence of inputs as a sequence of <see cref="StringWithQualityHeaderValue"/> values using string parsing rules. 158public static IList<StringWithQualityHeaderValue> ParseStrictList(IList<string>? input) 164/// Attempts to parse the sequence of values as a sequence of <see cref="StringWithQualityHeaderValue"/>. 168/// <returns><see langword="true"/> if all inputs are valid <see cref="StringWithQualityHeaderValue"/>, otherwise <see langword="false"/>.</returns> 169public static bool TryParseList(IList<string>? input, [NotNullWhen(true)] out IList<StringWithQualityHeaderValue>? parsedValues) 175/// Attempts to parse the sequence of values as a sequence of <see cref="StringWithQualityHeaderValue"/> using string parsing rules. 179/// <returns><see langword="true"/> if all inputs are valid <see cref="StringWithQualityHeaderValue"/>, otherwise <see langword="false"/>.</returns> 180public static bool TryParseStrictList(IList<string>? input, [NotNullWhen(true)] out IList<StringWithQualityHeaderValue>? parsedValues) 185private static int GetStringWithQualityLength(StringSegment input, int startIndex, out StringWithQualityHeaderValue? parsedValue) 204StringWithQualityHeaderValue result = new StringWithQualityHeaderValue(); 228private static bool TryReadQuality(StringSegment input, StringWithQualityHeaderValue result, ref int index)
StringWithQualityHeaderValueComparer.cs (5)
15public class StringWithQualityHeaderValueComparer : IComparer<StringWithQualityHeaderValue> 29/// Compares two <see cref="StringWithQualityHeaderValue"/> based on their quality value 33/// a sequence of <see cref="StringWithQualityHeaderValue"/> following their q-values ending up with any 40StringWithQualityHeaderValue? stringWithQuality1, 41StringWithQualityHeaderValue? stringWithQuality2)
Microsoft.Net.Http.Headers.Tests (42)
StringWithQualityHeaderValueComparerTest.cs (2)
52var unsortedValues = StringWithQualityHeaderValue.ParseList(unsorted.ToList()); 53var expectedSortedValues = StringWithQualityHeaderValue.ParseList(expectedSorted.ToList());
StringWithQualityHeaderValueTest.cs (40)
11var value = new StringWithQualityHeaderValue("token"); 23var value = new StringWithQualityHeaderValue("token", 0.5); 38var value = new StringWithQualityHeaderValue("token"); 58var value1 = new StringWithQualityHeaderValue("t", 0.123); 59var value2 = new StringWithQualityHeaderValue("t", 0.123); 60var value3 = new StringWithQualityHeaderValue("T", 0.123); 61var value4 = new StringWithQualityHeaderValue("t"); 62var value5 = new StringWithQualityHeaderValue("x", 0.123); 63var value6 = new StringWithQualityHeaderValue("t", 0.5); 64var value7 = new StringWithQualityHeaderValue("t", 0.1234); 65var value8 = new StringWithQualityHeaderValue("T"); 66var value9 = new StringWithQualityHeaderValue("x"); 81var value1 = new StringWithQualityHeaderValue("t", 0.123); 82var value2 = new StringWithQualityHeaderValue("t", 0.123); 83var value3 = new StringWithQualityHeaderValue("T", 0.123); 84var value4 = new StringWithQualityHeaderValue("t"); 85var value5 = new StringWithQualityHeaderValue("x", 0.123); 86var value6 = new StringWithQualityHeaderValue("t", 0.5); 87var value7 = new StringWithQualityHeaderValue("t", 0.1234); 88var value8 = new StringWithQualityHeaderValue("T"); 89var value9 = new StringWithQualityHeaderValue("x"); 161Assert.Throws<FormatException>(() => StringWithQualityHeaderValue.Parse(input)); 217IList<StringWithQualityHeaderValue> results = StringWithQualityHeaderValue.ParseList(inputs); 254IList<StringWithQualityHeaderValue> results = StringWithQualityHeaderValue.ParseStrictList(inputs); 291Assert.True(StringWithQualityHeaderValue.TryParseList(inputs, out var results)); 328Assert.True(StringWithQualityHeaderValue.TryParseStrictList(inputs, out var results)); 366var results = StringWithQualityHeaderValue.ParseList(inputs); 404Assert.Throws<FormatException>(() => StringWithQualityHeaderValue.ParseStrictList(inputs)); 424Assert.True(StringWithQualityHeaderValue.TryParseList(inputs, out var results)); 462Assert.False(StringWithQualityHeaderValue.TryParseStrictList(inputs, out var results)); 467private void CheckValidParse(string? input, StringWithQualityHeaderValue expectedResult) 469var result = StringWithQualityHeaderValue.Parse(input); 473private void CheckValidTryParse(string? input, StringWithQualityHeaderValue expectedResult) 475Assert.True(StringWithQualityHeaderValue.TryParse(input, out var result)); 481Assert.False(StringWithQualityHeaderValue.TryParse(input, out var result));