| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // Copied from https://github.com/aspnet/AspNetCore/tree/master/src/Http/Headers/src |
| | 5 | |
|
| | 6 | | using System; |
| | 7 | |
|
| | 8 | | #pragma warning disable IDE0016 // Simplify null check |
| | 9 | | #pragma warning disable IDE0044 // Make field readonly |
| | 10 | |
|
| | 11 | | namespace Azure.Core.Http.Multipart |
| | 12 | | { |
| | 13 | | internal sealed class GenericHeaderParser<T> : BaseHeaderParser<T> |
| | 14 | | { |
| | 15 | | internal delegate int GetParsedValueLengthDelegate(StringSegment value, int startIndex, out T parsedValue); |
| | 16 | |
|
| | 17 | | private GetParsedValueLengthDelegate _getParsedValueLength; |
| | 18 | |
|
| | 19 | | internal GenericHeaderParser(bool supportsMultipleValues, GetParsedValueLengthDelegate getParsedValueLength) |
| 0 | 20 | | : base(supportsMultipleValues) |
| | 21 | | { |
| 0 | 22 | | if (getParsedValueLength == null) |
| | 23 | | { |
| 0 | 24 | | throw new ArgumentNullException(nameof(getParsedValueLength)); |
| | 25 | | } |
| | 26 | |
|
| 0 | 27 | | _getParsedValueLength = getParsedValueLength; |
| 0 | 28 | | } |
| | 29 | |
|
| | 30 | | protected override int GetParsedValueLength(StringSegment value, int startIndex, out T parsedValue) |
| | 31 | | { |
| 0 | 32 | | return _getParsedValueLength(value, startIndex, out parsedValue); |
| | 33 | | } |
| | 34 | | } |
| | 35 | | } |