src/packages/EmbedIO/Utilities/NameValueCollectionExtensions.cs
/// <summary>
/// <para>Converts a <see cref="NameValueCollection"/> to a dictionary of objects.</para>
/// <para>Values in the returned dictionary will wither be strings, or arrays of strings,
/// depending on the presence of multiple values for the same key in the collection.</para>
/// </summary>
/// <param name="this">The <see cref="NameValueCollection"/> on which this method is called.</param>
/// <returns>A <see cref="Dictionary{TKey,TValue}"/> associating the collection's keys
/// with their values.</returns>
/// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
Converts a  to a dictionary of objects.Values in the returned dictionary will wither be strings, or arrays of strings,
depending on the presence of multiple values for the same key in the collection.
Converts a to a dictionary of objects . Values in the returned dictionary will wither be strings or arrays of strings depending on the presence of multiple values for the same key in the collection .
public static Dictionary<string, object?> ToDictionary(this NameValueCollection @this)
            => @this.Keys.Cast<string>().ToDictionary(key => key, key =>
            {
                var values = @this.GetValues(key);
                if (values == null)
                    return null;
                return values.Length switch {
                    0 => null,
                    1 => (object)values[0],
                    _ => (object)values,
                };
            });
public static Dictionary < string , object ? > ToDictionary ( this NameValueCollection @this ) => @this . Keys . Cast < string > ( ) . ToDictionary ( key => key , key => { var values = @this . GetValues ( key ) ; if ( values == null ) return null ; return values . Length switch { 0 => null , 1 => ( object ) values [ 0 ] , _ => ( object ) values , } ; } ) ;
Converts a  to a dictionary of objects.Values in the returned dictionary will wither be strings, or arrays of strings,
depending on the presence of multiple values for the same key in the collection.
Converts a to a dictionary of objects . Values in the returned dictionary will wither be strings or arrays of strings depending on the presence of multiple values for the same key in the collection .
A  associating the collection's keys
with their values.
A associating the collection ' s keys with their values .
None
NameValueCollection
this
this
The  on which this method is called.
The on which this method is called .