public override bool Equals(object obj) { RangeHeaderValue other = obj as RangeHeaderValue; if (other == null) { return(false); } return(string.Equals(_unit, other._unit, StringComparison.OrdinalIgnoreCase) && HeaderUtilities.AreEqualCollections(_ranges, other._ranges)); }
private RangeHeaderValue(RangeHeaderValue source) { Debug.Assert(source != null); _unit = source._unit; if (source._ranges != null) { foreach (RangeItemHeaderValue range in source._ranges) { this.Ranges.Add((RangeItemHeaderValue)((ICloneable)range).Clone()); } } }
public static bool TryParse(string input, out RangeHeaderValue parsedValue) { int index = 0; object output; parsedValue = null; if (GenericHeaderParser.RangeParser.TryParseValue(input, null, ref index, out output)) { parsedValue = (RangeHeaderValue)output; return(true); } return(false); }
internal static int GetRangeLength(string input, int startIndex, out object parsedValue) { Debug.Assert(startIndex >= 0); parsedValue = null; if (string.IsNullOrEmpty(input) || (startIndex >= input.Length)) { return(0); } // Parse the unit string: <unit> in '<unit>=<from1>-<to1>, <from2>-<to2>' int unitLength = HttpRuleParser.GetTokenLength(input, startIndex); if (unitLength == 0) { return(0); } RangeHeaderValue result = new RangeHeaderValue(); result._unit = input.Substring(startIndex, unitLength); int current = startIndex + unitLength; current = current + HttpRuleParser.GetWhitespaceLength(input, current); if ((current == input.Length) || (input[current] != '=')) { return(0); } current++; // skip '=' separator current = current + HttpRuleParser.GetWhitespaceLength(input, current); int rangesLength = RangeItemHeaderValue.GetRangeItemListLength(input, current, result.Ranges); if (rangesLength == 0) { return(0); } current = current + rangesLength; Debug.Assert(current == input.Length, "GetRangeItemListLength() should consume the whole string or fail."); parsedValue = result; return(current - startIndex); }