31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System;
|
|
|
|
namespace Microsoft.Net.Http.Headers
|
|
{
|
|
internal sealed class GenericHeaderParser<T> : BaseHeaderParser<T>
|
|
{
|
|
internal delegate int GetParsedValueLengthDelegate(string value, int startIndex, out T parsedValue);
|
|
|
|
private GetParsedValueLengthDelegate _getParsedValueLength;
|
|
|
|
internal GenericHeaderParser(bool supportsMultipleValues, GetParsedValueLengthDelegate getParsedValueLength)
|
|
: base(supportsMultipleValues)
|
|
{
|
|
if (getParsedValueLength == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(getParsedValueLength));
|
|
}
|
|
|
|
_getParsedValueLength = getParsedValueLength;
|
|
}
|
|
|
|
protected override int GetParsedValueLength(string value, int startIndex, out T parsedValue)
|
|
{
|
|
return _getParsedValueLength(value, startIndex, out parsedValue);
|
|
}
|
|
}
|
|
}
|