/// <summary>
    /// Get the associated values from the collection separated into individual values.
    /// Quoted values will not be split, and the quotes will be removed.
    /// </summary>
    /// <param name="headers">The <see cref="IHeaderDictionary"/> to use.</param>
    /// <param name="key">The header name.</param>
    /// <returns>the associated values from the collection separated into individual values, or StringValues.Empty if the key is not present.</returns>
    public static string[] GetCommaSeparatedValues(this IHeaderDictionary headers, string key)
    {
        // GetHeaderSplit will return only non-null elements of the given IHeaderDictionary.
#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type.
        return(ParsingHelpers.GetHeaderSplit(headers, key).ToArray());

#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type.
    }
        public void SplitManyHeaders()
        {
            var values = ParsingHelpers.GetHeaderSplit(_dictionary, "manyValue");

            if (values.Count != 6)
            {
                throw new Exception();
            }
        }
        public void SplitDoubleHeader()
        {
            var values = ParsingHelpers.GetHeaderSplit(_dictionary, "doubleValue");

            if (values.Count != 2)
            {
                throw new Exception();
            }
        }
        public void SplitSingleQuotedHeader()
        {
            var values = ParsingHelpers.GetHeaderSplit(_dictionary, "singleValueQuoted");

            if (values.Count != 1)
            {
                throw new Exception();
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Get the associated values from the collection separated into individual values.
 /// Quoted values will not be split, and the quotes will be removed.
 /// </summary>
 /// <param name="headers">The <see cref="IHeaderDictionary"/> to use.</param>
 /// <param name="key">The header name.</param>
 /// <returns>the associated values from the collection separated into individual values, or StringValues.Empty if the key is not present.</returns>
 public static string[] GetCommaSeparatedValues(this IHeaderDictionary headers, string key)
 {
     return(ParsingHelpers.GetHeaderSplit(headers, key));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Get the associated values from the collection separated into individual values.
        /// Quoted values will not be split, and the quotes will be removed.
        /// </summary>
        /// <param name="key">The header name.</param>
        /// <returns>the associated values from the collection separated into individual values, or null if the key is not present.</returns>
        public IList <string> GetCommaSeparatedValues(string key)
        {
            IEnumerable <string> values = ParsingHelpers.GetHeaderSplit(Store, key);

            return(values == null ? null : values.ToList());
        }