Class DictionaryExtensions
Extension methods for
Inheritance
Namespace: X10D.Collections
Assembly: X10D.dll
Syntax
public static class DictionaryExtensions : object
Methods
| Improve this Doc View SourceAddOrUpdate<TKey, TValue>(Dictionary<TKey, TValue>, TKey, TValue, Func<TKey, TValue, TValue>)
Adds a key/value pair to the
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<TKey, TValue> | dictionary | The dictionary to update. |
TKey | key | The key to be added or whose value should be updated. |
TValue | addValue | The value to be added for an absent key. |
Func<TKey, TValue, TValue> | updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
Returns
Type | Description |
---|---|
TValue | The new value for the key. This will be either be |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
AddOrUpdate<TKey, TValue>(Dictionary<TKey, TValue>, TKey, Func<TKey, TValue>, Func<TKey, TValue, TValue>)
Uses the specified functions to add a key/value pair to the
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<TKey, TValue> | dictionary | The dictionary to update. |
TKey | key | The key to be added or whose value should be updated. |
Func<TKey, TValue> | addValueFactory | The function used to generate a value for an absent key. |
Func<TKey, TValue, TValue> | updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
Returns
Type | Description |
---|---|
TValue | The new value for the key. This will be either be the result of |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue, Func<TKey, TValue, TValue>)
Adds a key/value pair to the
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | dictionary | The dictionary to update. |
TKey | key | The key to be added or whose value should be updated. |
TValue | addValue | The value to be added for an absent key. |
Func<TKey, TValue, TValue> | updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
Returns
Type | Description |
---|---|
TValue | The new value for the key. This will be either be |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
AddOrUpdate<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TKey, TValue>, Func<TKey, TValue, TValue>)
Uses the specified functions to add a key/value pair to the
Declaration
public static TValue AddOrUpdate<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | dictionary | The dictionary to update. |
TKey | key | The key to be added or whose value should be updated. |
Func<TKey, TValue> | addValueFactory | The function used to generate a value for an absent key. |
Func<TKey, TValue, TValue> | updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
Returns
Type | Description |
---|---|
TValue | The new value for the key. This will be either be the result of |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
AddOrUpdate<TKey, TValue, TArg>(Dictionary<TKey, TValue>, TKey, Func<TKey, TArg, TValue>, Func<TKey, TValue, TArg, TValue>, TArg)
Uses the specified functions and argument to add a key/value pair to the
Declaration
public static TValue AddOrUpdate<TKey, TValue, TArg>(this Dictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TArg, TValue> addValueFactory, Func<TKey, TValue, TArg, TValue> updateValueFactory, TArg factoryArgument)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<TKey, TValue> | dictionary | The dictionary to update. |
TKey | key | The key to be added or whose value should be updated. |
Func<TKey, TArg, TValue> | addValueFactory | The function used to generate a value for an absent key. |
Func<TKey, TValue, TArg, TValue> | updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
TArg | factoryArgument | An argument to pass into |
Returns
Type | Description |
---|---|
TValue | The new value for the key. This will be either be the result of |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
TArg | The type of an argument to pass into |
AddOrUpdate<TKey, TValue, TArg>(IDictionary<TKey, TValue>, TKey, Func<TKey, TArg, TValue>, Func<TKey, TValue, TArg, TValue>, TArg)
Uses the specified functions and argument to add a key/value pair to the
Declaration
public static TValue AddOrUpdate<TKey, TValue, TArg>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TArg, TValue> addValueFactory, Func<TKey, TValue, TArg, TValue> updateValueFactory, TArg factoryArgument)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<TKey, TValue> | dictionary | The dictionary to update. |
TKey | key | The key to be added or whose value should be updated. |
Func<TKey, TArg, TValue> | addValueFactory | The function used to generate a value for an absent key. |
Func<TKey, TValue, TArg, TValue> | updateValueFactory | The function used to generate a new value for an existing key based on the key's existing value. |
TArg | factoryArgument | An argument to pass into |
Returns
Type | Description |
---|---|
TValue | The new value for the key. This will be either be the result of |
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys in the dictionary. |
TValue | The type of the values in the dictionary. |
TArg | The type of an argument to pass into |
ToConnectionString<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>)
Converts an
Declaration
public static string ToConnectionString<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source dictionary. |
Returns
Type | Description |
---|---|
System.String | A |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key element of the key/value pair. |
TValue | The type of the value element of the key/value pair. |
ToConnectionString<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>, Func<TKey, String>, Func<TValue, Nullable<String>>)
Converts an
Declaration
public static string ToConnectionString<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source, Func<TKey, string> keySelector, Func<TValue, string?> valueSelector)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source dictionary. |
Func<TKey, System.String> | keySelector | A transform function to apply to the |
Func<TValue, System.Nullable<System.String>> | valueSelector | A transform function to apply to the |
Returns
Type | Description |
---|---|
System.String | A |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key element of the key/value pair. |
TValue | The type of the value element of the key/value pair. |
ToConnectionString<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>, Func<TValue, Nullable<String>>)
Converts an
Declaration
public static string ToConnectionString<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source, Func<TValue, string?> selector)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source dictionary. |
Func<TValue, System.Nullable<System.String>> | selector | A transform function to apply to the |
Returns
Type | Description |
---|---|
System.String | A |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key element of the key/value pair. |
TValue | The type of the value element of the key/value pair. |
ToGetParameters<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>)
Converts an
Declaration
public static string ToGetParameters<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source dictionary. |
Returns
Type | Description |
---|---|
System.String | A |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key element of the key/value pair. |
TValue | The type of the value element of the key/value pair. |
ToGetParameters<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>, Func<TKey, String>, Func<TValue, Nullable<String>>)
Converts an
Declaration
public static string ToGetParameters<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source, Func<TKey, string> keySelector, Func<TValue, string?> valueSelector)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source dictionary. |
Func<TKey, System.String> | keySelector | A transform function to apply to the |
Func<TValue, System.Nullable<System.String>> | valueSelector | A transform function to apply to the |
Returns
Type | Description |
---|---|
System.String | A |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key element of the key/value pair. |
TValue | The type of the value element of the key/value pair. |
ToGetParameters<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>, Func<TValue, Nullable<String>>)
Converts an
Declaration
public static string ToGetParameters<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source, Func<TValue, string?> selector)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source dictionary. |
Func<TValue, System.Nullable<System.String>> | selector | A transform function to apply to the |
Returns
Type | Description |
---|---|
System.String | A |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key element of the key/value pair. |
TValue | The type of the value element of the key/value pair. |