Extension methods for Dictionary & ConcurrentDictionary.
InheritanceSystem.Object
Namespace: Umbraco.Extensions Assembly: Umbraco.Core.dll Syntaxpublic static class DictionaryExtensions
Methods View Source ContainsKeyIgnoreCase<TValue>(IDictionary<String, TValue>, String)
contains key ignore case.
Declarationpublic static bool ContainsKeyIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key)
Parameters Type Name Description System.Collections.IDictionary<System.String, TValue> dictionary
The dictionary.
System.String keyThe key.
Returns Type Description System.BooleanThe contains key ignore case.
Type Parameters Name Description TValueValue Type
View Source ConvertTo<TKeyOut, TValOut>(IDictionary)Converts a dictionary to another type by only using direct casting
Declarationpublic static IDictionary<TKeyOut, TValOut> ConvertTo<TKeyOut, TValOut>(this IDictionary d)
Parameters Type Name Description System.Collections.IDictionary d Returns Type Description System.Collections.IDictionary<TKeyOut, TValOut> Type Parameters Name Description TKeyOut TValOut View Source ConvertTo<TKeyOut, TValOut>(IDictionary, Func<Object, TKeyOut>, Func<Object, TValOut>)
Converts a dictionary to another type using the specified converters
Declarationpublic static IDictionary<TKeyOut, TValOut> ConvertTo<TKeyOut, TValOut>(this IDictionary d, Func<object, TKeyOut> keyConverter, Func<object, TValOut> valConverter)
Parameters Type Name Description System.Collections.IDictionary d Func<System.Object, TKeyOut> keyConverter Func<System.Object, TValOut> valConverter Returns Type Description System.Collections.IDictionary<TKeyOut, TValOut> Type Parameters Name Description TKeyOut TValOut View Source GetOrCreate<TKey, TVal>(IDictionary<TKey, TVal>, TKey)
Method to Get a value by the key. If the key doesn't exist it will create a new TVal object for the key and return it.
Declarationpublic static TVal GetOrCreate<TKey, TVal>(this IDictionary<TKey, TVal> dict, TKey key)
where TVal : class, new()
Parameters Type Name Description System.Collections.IDictionary<TKey, TVal> dict TKey key Returns Type Parameters Name Description TKey TVal View Source GetValue<TKey, TVal>(IDictionary<TKey, TVal>, TKey, TVal)
Returns the value of the key value based on the key, if the key is not found, a null value is returned
Declarationpublic static TVal GetValue<TKey, TVal>(this IDictionary<TKey, TVal> d, TKey key, TVal defaultValue = null)
Parameters Type Name Description System.Collections.IDictionary<TKey, TVal> d
The d.
TKey keyThe key.
TVal defaultValueThe default value.
Returns Type Parameters Name Description TKeyThe type of the key.
TValThe type of the val.
View Source GetValueAsString<TKey, TVal>(IDictionary<TKey, TVal>, TKey)Returns the value of the key value based on the key as it's string value, if the key is not found, then an empty string is returned
Declarationpublic static string GetValueAsString<TKey, TVal>(this IDictionary<TKey, TVal> d, TKey key)
Parameters Type Name Description System.Collections.IDictionary<TKey, TVal> d TKey key Returns Type Description System.String Type Parameters Name Description TKey TVal View Source GetValueAsString<TKey, TVal>(IDictionary<TKey, TVal>, TKey, String)
Returns the value of the key value based on the key as it's string value, if the key is not found or is an empty string, then the provided default value is returned
Declarationpublic static string GetValueAsString<TKey, TVal>(this IDictionary<TKey, TVal> d, TKey key, string defaultValue)
Parameters Type Name Description System.Collections.IDictionary<TKey, TVal> d TKey key System.String defaultValue Returns Type Description System.String Type Parameters Name Description TKey TVal View Source GetValueIgnoreCase<TValue>(IDictionary<String, TValue>, String)
The get entry ignore case.
Declarationpublic static TValue GetValueIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key)
Parameters Type Name Description System.Collections.IDictionary<System.String, TValue> dictionary
The dictionary.
System.String keyThe key.
Returns Type Description TValueThe entry
Type Parameters Name Description TValueThe type
View Source GetValueIgnoreCase<TValue>(IDictionary<String, TValue>, String, TValue)The get entry ignore case.
Declarationpublic static TValue GetValueIgnoreCase<TValue>(this IDictionary<string, TValue> dictionary, string key, TValue defaultValue)
Parameters Type Name Description System.Collections.IDictionary<System.String, TValue> dictionary
The dictionary.
System.String keyThe key.
TValue defaultValueThe default value.
Returns Type Description TValueThe entry
Type Parameters Name Description TValueThe type
View Source MergeLeft<T, TK, TV>(T, IDictionary<TK, TV>, Boolean)Merges all key/values from the sources dictionaries into the destination dictionary
Declarationpublic static void MergeLeft<T, TK, TV>(this T destination, IDictionary<TK, TV> source, bool overwrite = false)
where T : IDictionary<TK, TV>
Parameters Type Name Description T destination
The source dictionary to merge other dictionaries into
System.Collections.IDictionary<TK, TV> sourceThe other dictionary to merge values from
System.Boolean overwriteBy default all values will be retained in the destination if the same keys exist in the sources but this can changed if overwrite = true, then any key/value found in any of the sources will overwritten in the destination. Note that it will just use the last found key/value if this is true.
Type Parameters View Source MergeLeft<T, TK, TV>(T, IEnumerable<IDictionary<TK, TV>>, Boolean)Merges all key/values from the sources dictionaries into the destination dictionary
Declarationpublic static void MergeLeft<T, TK, TV>(this T destination, IEnumerable<IDictionary<TK, TV>> sources, bool overwrite = false)
where T : IDictionary<TK, TV>
Parameters Type Name Description T destination
The source dictionary to merge other dictionaries into
System.Collections.IEnumerable<System.Collections.IDictionary<TK, TV>> sourcesThe other dictionaries to merge values from
System.Boolean overwriteBy default all values will be retained in the destination if the same keys exist in the sources but this can changed if overwrite = true, then any key/value found in any of the sources will overwritten in the destination. Note that it will just use the last found key/value if this is true.
Type Parameters View Source ToDictionaryAsync<TInput, TKey, TValue>(IEnumerable<TInput>, Func<TInput, TKey>, Func<TInput, Task<TValue>>) Declarationpublic static async Task<Dictionary<TKey, TValue>> ToDictionaryAsync<TInput, TKey, TValue>(this IEnumerable<TInput> enumerable, Func<TInput, TKey> syncKeySelector, Func<TInput, Task<TValue>> asyncValueSelector)
Parameters Type Name Description System.Collections.IEnumerable<TInput> enumerable Func<TInput, TKey> syncKeySelector Func<TInput, Task<TValue>> asyncValueSelector Returns Type Description Task<Dictionary<TKey, TValue>> Type Parameters Name Description TInput TKey TValue View Source ToNameValueCollection(IDictionary<String, String>)
Converts a dictionary to a NameValueCollection
Declarationpublic static NameValueCollection ToNameValueCollection(this IDictionary<string, string> d)
Parameters Type Name Description System.Collections.IDictionary<System.String, System.String> d Returns Type Description System.Collections.Specialized.NameValueCollection View Source ToQueryString(IDictionary<String, Object>)
Converts a dictionary object to a query string representation such as: firstname=shannon&lastname=deminick.
Declarationpublic static string ToQueryString(this IDictionary<string, object> d)
Parameters Type Name Description System.Collections.IDictionary<System.String, System.Object> d Returns Type Description System.String View Source TryUpdate<TKey, TValue>(ConcurrentDictionary<TKey, TValue>, TKey, Func<TValue, TValue>)
Updates an item with the specified key with the specified value
Declarationpublic static bool TryUpdate<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, TKey key, Func<TValue, TValue> updateFactory)
Parameters Type Name Description System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue> dict TKey key Func<TValue, TValue> updateFactory Returns Type Description System.Boolean Type Parameters Name Description TKey TValue View Source TryUpdateOptimisitic<TKey, TValue>(ConcurrentDictionary<TKey, TValue>, TKey, Func<TValue, TValue>)
Updates an item with the specified key with the specified value
Declarationpublic static bool TryUpdateOptimisitic<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, TKey key, Func<TValue, TValue> updateFactory)
Parameters Type Name Description System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue> dict TKey key Func<TValue, TValue> updateFactory Returns Type Description System.Boolean Type Parameters Name Description TKey TValue
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4