private static bool TryCreateContentRange(string input, string unit, int fromStartIndex, int fromLength,
int toStartIndex, int toLength, int lengthStartIndex, int lengthLength, out object parsedValue)
{
parsedValue = null;
long from = 0;
if ((fromLength > 0) && !HeaderUtilities.TryParseInt64(input.Substring(fromStartIndex, fromLength), out from))
{
return false;
}
long to = 0;
if ((toLength > 0) && !HeaderUtilities.TryParseInt64(input.Substring(toStartIndex, toLength), out to))
{
return false;
}
// 'from' must not be greater than 'to'
if ((fromLength > 0) && (toLength > 0) && (from > to))
{
return false;
}
long length = 0;
if ((lengthLength > 0) && !HeaderUtilities.TryParseInt64(input.Substring(lengthStartIndex, lengthLength),
out length))
{
return false;
}
// 'from' and 'to' must be less than 'length'
if ((toLength > 0) && (lengthLength > 0) && (to >= length))
{
return false;
}
ContentRangeHeaderValue result = new ContentRangeHeaderValue();
result._unit = unit;
if (fromLength > 0)
{
result._from = from;
result._to = to;
}
if (lengthLength > 0)
{
result._length = length;
}
parsedValue = result;
return true;
}