protected override int GetParsedValueLength(string value, int startIndex, object storeValue,
                                                    out object parsedValue)
        {
            TransferCodingHeaderValue temp = null;
            int resultLength = TransferCodingHeaderValue.GetTransferCodingLength(value, startIndex,
                                                                                 _transferCodingCreator, out temp);

            parsedValue = temp;
            return(resultLength);
        }
        public override bool Equals(object obj)
        {
            TransferCodingHeaderValue other = obj as TransferCodingHeaderValue;

            if (other == null)
            {
                return(false);
            }

            return(string.Equals(_value, other._value, StringComparison.OrdinalIgnoreCase) &&
                   HeaderUtilities.AreEqualCollections(_parameters, other._parameters));
        }
        internal static int GetTransferCodingLength(string input, int startIndex,
                                                    Func <TransferCodingHeaderValue> transferCodingCreator, out TransferCodingHeaderValue parsedValue)
        {
            Debug.Assert(transferCodingCreator != null);
            Debug.Assert(startIndex >= 0);

            parsedValue = null;

            if (string.IsNullOrEmpty(input) || (startIndex >= input.Length))
            {
                return(0);
            }

            // Caller must remove leading whitespace. If not, we'll return 0.
            int valueLength = HttpRuleParser.GetTokenLength(input, startIndex);

            if (valueLength == 0)
            {
                return(0);
            }

            string value   = input.Substring(startIndex, valueLength);
            int    current = startIndex + valueLength;

            current = current + HttpRuleParser.GetWhitespaceLength(input, current);
            TransferCodingHeaderValue transferCodingHeader = null;

            // If we're not done and we have a parameter delimiter, then we have a list of parameters.
            if ((current < input.Length) && (input[current] == ';'))
            {
                transferCodingHeader        = transferCodingCreator();
                transferCodingHeader._value = value;

                current++; // skip delimiter.
                int parameterLength = NameValueHeaderValue.GetNameValueListLength(input, current, ';',
                                                                                  (ObjectCollection <NameValueHeaderValue>)transferCodingHeader.Parameters);

                if (parameterLength == 0)
                {
                    return(0);
                }

                parsedValue = transferCodingHeader;
                return(current + parameterLength - startIndex);
            }

            // We have a transfer coding without parameters.
            transferCodingHeader        = transferCodingCreator();
            transferCodingHeader._value = value;
            parsedValue = transferCodingHeader;
            return(current - startIndex);
        }
        public static bool TryParse(string input, out TransferCodingHeaderValue parsedValue)
        {
            int    index = 0;
            object output;

            parsedValue = null;

            if (TransferCodingHeaderParser.SingleValueParser.TryParseValue(input, null, ref index, out output))
            {
                parsedValue = (TransferCodingHeaderValue)output;
                return(true);
            }
            return(false);
        }
        protected TransferCodingHeaderValue(TransferCodingHeaderValue source)
        {
            Debug.Assert(source != null);

            _value = source._value;

            if (source._parameters != null)
            {
                foreach (var parameter in source._parameters)
                {
                    this.Parameters.Add((NameValueHeaderValue)((ICloneable)parameter).Clone());
                }
            }
        }