| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Diagnostics.CodeAnalysis; |
| | | 6 | | |
| | | 7 | | namespace System.Net.Http.Headers |
| | | 8 | | { |
| | | 9 | | public sealed class TransferCodingWithQualityHeaderValue : TransferCodingHeaderValue, ICloneable |
| | | 10 | | { |
| | | 11 | | public double? Quality |
| | | 12 | | { |
| | 0 | 13 | | get => HeaderUtilities.GetQuality((UnvalidatedObjectCollection<NameValueHeaderValue>)Parameters); |
| | 0 | 14 | | set => HeaderUtilities.SetQuality((UnvalidatedObjectCollection<NameValueHeaderValue>)Parameters, value); |
| | | 15 | | } |
| | | 16 | | |
| | 92426 | 17 | | internal TransferCodingWithQualityHeaderValue() |
| | 92426 | 18 | | { |
| | | 19 | | // Used by the parser to create a new instance of this type. |
| | 92426 | 20 | | } |
| | | 21 | | |
| | | 22 | | public TransferCodingWithQualityHeaderValue(string value) |
| | 0 | 23 | | : base(value) |
| | 0 | 24 | | { |
| | 0 | 25 | | } |
| | | 26 | | |
| | | 27 | | public TransferCodingWithQualityHeaderValue(string value, double quality) |
| | 0 | 28 | | : base(value) |
| | 0 | 29 | | { |
| | 0 | 30 | | Quality = quality; |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | private TransferCodingWithQualityHeaderValue(TransferCodingWithQualityHeaderValue source) |
| | 0 | 34 | | : base(source) |
| | 0 | 35 | | { |
| | | 36 | | // No additional members to initialize here. This constructor is used by Clone(). |
| | 0 | 37 | | } |
| | | 38 | | |
| | | 39 | | object ICloneable.Clone() |
| | 0 | 40 | | { |
| | 0 | 41 | | return new TransferCodingWithQualityHeaderValue(this); |
| | 0 | 42 | | } |
| | | 43 | | |
| | | 44 | | public static new TransferCodingWithQualityHeaderValue Parse(string input) |
| | 0 | 45 | | { |
| | 0 | 46 | | int index = 0; |
| | 0 | 47 | | return (TransferCodingWithQualityHeaderValue)TransferCodingHeaderParser.SingleValueWithQualityParser |
| | 0 | 48 | | .ParseValue(input, null, ref index); |
| | 0 | 49 | | } |
| | | 50 | | |
| | | 51 | | public static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out TransferCodingWithQuality |
| | 0 | 52 | | { |
| | 0 | 53 | | int index = 0; |
| | 0 | 54 | | parsedValue = null; |
| | | 55 | | |
| | 0 | 56 | | if (TransferCodingHeaderParser.SingleValueWithQualityParser.TryParseValue( |
| | 0 | 57 | | input, null, ref index, out object? output)) |
| | 0 | 58 | | { |
| | 0 | 59 | | parsedValue = (TransferCodingWithQualityHeaderValue)output!; |
| | 0 | 60 | | return true; |
| | | 61 | | } |
| | 0 | 62 | | return false; |
| | 0 | 63 | | } |
| | | 64 | | } |
| | | 65 | | } |