DictionaryExtensions
Assembly: ServiceStack.Common.dll
View Source
Declaration
public static class DictionaryExtensions
Methods
GetValueOrDefault<TValue, TKey>(Dictionary<TKey, TValue>, TKey)
View Source
Declaration
public static TValue GetValueOrDefault<TValue, TKey>(this Dictionary<TKey, TValue> dictionary, TKey key)
Returns
<TValue>
Parameters
Type | Name |
---|---|
System.Collections.Generic.Dictionary<<TKey>,<TValue>> | dictionary |
<TKey> | key |
Type Parameters
TValue
TKey
GetValue<TValue, TKey>(Dictionary<TKey, TValue>, TKey, Func<TValue>)
View Source
Declaration
public static TValue GetValue<TValue, TKey>(this Dictionary<TKey, TValue> dictionary, TKey key, Func<TValue> defaultValue)
Returns
<TValue>
Parameters
Type | Name |
---|---|
System.Collections.Generic.Dictionary<<TKey>,<TValue>> | dictionary |
<TKey> | key |
System.Func<<TValue>> | defaultValue |
Type Parameters
TValue
TKey
IsNullOrEmpty(IDictionary)
View Source
Declaration
public static bool IsNullOrEmpty(this IDictionary dictionary)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Collections.IDictionary | dictionary |
ForEach<TKey, TValue>(Dictionary<TKey, TValue>, Action<TKey, TValue>)
View Source
Declaration
public static void ForEach<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Action<TKey, TValue> onEachFn)
Parameters
Type | Name |
---|---|
System.Collections.Generic.Dictionary<<TKey>,<TValue>> | dictionary |
System.Action<<TKey>,<TValue>> | onEachFn |
Type Parameters
TKey
TValue
UnorderedEquivalentTo<K, V>(IDictionary<K, V>, IDictionary<K, V>)
View Source
Declaration
public static bool UnorderedEquivalentTo<K, V>(this IDictionary<K, V> thisMap, IDictionary<K, V> otherMap)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Collections.Generic.IDictionary<<K>,<V>> | thisMap |
System.Collections.Generic.IDictionary<<K>,<V>> | otherMap |
Type Parameters
K
V
ConvertAll<T, K, V>(IDictionary<K, V>, Func<K, V, T>)
View Source
Declaration
public static List<T> ConvertAll<T, K, V>(IDictionary<K, V> map, Func<K, V, T> createFn)
Returns
System.Collections.Generic.List<<T>>
Parameters
Type | Name |
---|---|
System.Collections.Generic.IDictionary<<K>,<V>> | map |
System.Func<<K>,<V>,<T>> | createFn |
Type Parameters
T
K
V
GetOrAdd<K, V>(Dictionary<K, V>, K, Func<K, V>)
View Source
Declaration
public static V GetOrAdd<K, V>(this Dictionary<K, V> map, K key, Func<K, V> createFn)
Returns
<V>
Parameters
Type | Name |
---|---|
System.Collections.Generic.Dictionary<<K>,<V>> | map |
<K> | key |
System.Func<<K>,<V>> | createFn |
Type Parameters
K
V
PairWith<TKey, TValue>(TKey, TValue)
View Source
Declaration
public static KeyValuePair<TKey, TValue> PairWith<TKey, TValue>(this TKey key, TValue value)
Returns
System.Collections.Generic.KeyValuePair<<TKey>,<TValue>>
Parameters
Type | Name |
---|---|
<TKey> | key |
<TValue> | value |
Type Parameters
TKey
TValue
ToDictionary<TKey, TValue>(ConcurrentDictionary<TKey, TValue>)
View Source
Declaration
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> map)
Returns
System.Collections.Generic.Dictionary<<TKey>,<TValue>>
Parameters
Type | Name |
---|---|
System.Collections.Concurrent.ConcurrentDictionary<<TKey>,<TValue>> | map |
Type Parameters
TKey
TValue
ToConcurrentDictionary<TKey, TValue>(IDictionary<TKey, TValue>)
View Source
Declaration
public static ConcurrentDictionary<TKey, TValue> ToConcurrentDictionary<TKey, TValue>(this IDictionary<TKey, TValue> from)
Returns
System.Collections.Concurrent.ConcurrentDictionary<<TKey>,<TValue>>
Parameters
Type | Name |
---|---|
System.Collections.Generic.IDictionary<<TKey>,<TValue>> | from |
Type Parameters
TKey
TValue
TryRemove<TKey, TValue>(Dictionary<TKey, TValue>, TKey, out TValue)
View Source
Declaration
public static bool TryRemove<TKey, TValue>(this Dictionary<TKey, TValue> map, TKey key, out TValue value)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Collections.Generic.Dictionary<<TKey>,<TValue>> | map |
<TKey> | key |
<TValue> | value |
Type Parameters
TKey
TValue
RemoveKey<TKey, TValue>(Dictionary<TKey, TValue>, TKey)
View Source
Declaration
public static Dictionary<TKey, TValue> RemoveKey<TKey, TValue>(this Dictionary<TKey, TValue> map, TKey key)
Returns
System.Collections.Generic.Dictionary<<TKey>,<TValue>>
Parameters
Type | Name |
---|---|
System.Collections.Generic.Dictionary<<TKey>,<TValue>> | map |
<TKey> | key |
Type Parameters
TKey
TValue
MoveKey<TKey, TValue>(Dictionary<TKey, TValue>, TKey, TKey, Func<TValue, TValue>)
View Source
Declaration
public static Dictionary<TKey, TValue> MoveKey<TKey, TValue>(this Dictionary<TKey, TValue> map, TKey oldKey, TKey newKey, Func<TValue, TValue> valueFilter = null)
Returns
System.Collections.Generic.Dictionary<<TKey>,<TValue>>
Parameters
Type | Name |
---|---|
System.Collections.Generic.Dictionary<<TKey>,<TValue>> | map |
<TKey> | oldKey |
<TKey> | newKey |
System.Func<<TValue>,<TValue>> | valueFilter |
Type Parameters
TKey
TValue
Merge<TKey, TValue>(IDictionary<TKey, TValue>, IEnumerable<KeyValuePair<TKey, TValue>>[])
View Source
Declaration
public static Dictionary<TKey, TValue> Merge<TKey, TValue>(this IDictionary<TKey, TValue> initial, params IEnumerable<KeyValuePair<TKey, TValue>>[] withSources)
Returns
System.Collections.Generic.Dictionary<<TKey>,<TValue>>
Parameters
Type | Name |
---|---|
System.Collections.Generic.IDictionary<<TKey>,<TValue>> | initial |
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<<TKey>,<TValue>>>[] | withSources |
Type Parameters
TKey
TValue