Class DictionaryUtilities
Содержит служебные методы работы со словарями.
Inheritance
System.Object
DictionaryUtilities
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: Terrasoft.Common.dll
Syntax
public static class DictionaryUtilities
Methods
AddRange<T>(IDictionary<T, T>, IDictionary<T, T>)
Declaration
public static void AddRange<T>(this IDictionary<T, T> source, IDictionary<T, T> collection)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<T, T> |
source |
|
System.Collections.Generic.IDictionary<T, T> |
collection |
|
Type Parameters
AddRange<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>)
Declaration
public static void AddRange<TKey, TValue>(this IDictionary<TKey, TValue> source, IDictionary<TKey, TValue> collection)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<TKey, TValue> |
source |
|
System.Collections.Generic.IDictionary<TKey, TValue> |
collection |
|
Type Parameters
Name |
Description |
TKey |
|
TValue |
|
AddRangeIfNotExist<T>(Dictionary<T, T>, Dictionary<T, T>)
Осуществляет добавление в данный экземпляр заданного словаря, если элементы добавляемого словаря не входят
в состав данного экземпляра.
Declaration
public static void AddRangeIfNotExist<T>(this Dictionary<T, T> source, Dictionary<T, T> collection)
Parameters
Type |
Name |
Description |
System.Collections.Generic.Dictionary<T, T> |
source |
Словарь, в который осуществляется добавление.
|
System.Collections.Generic.Dictionary<T, T> |
collection |
Добавляемый словарь.
|
Type Parameters
ContainsValueIgnoreCase<T>(IDictionary<T, String>, String)
Determines whether the dictionary contains a specific value.
Compare string ignoring the case of the strings being compared.
Declaration
public static bool ContainsValueIgnoreCase<T>(this IDictionary<T, string> source, string value)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<T, System.String> |
source |
Source dictionary.
|
System.String |
value |
The value to locate in the dictionary.
The value can be null for reference types.
|
Returns
Type |
Description |
System.Boolean |
true if the dictionary contains an element with the specified value;
otherwise, false.
|
Type Parameters
Name |
Description |
T |
The type to be compared.
|
ForceGetValue<T1, T2>(IDictionary<T1, T2>, T1)
Declaration
public static T2 ForceGetValue<T1, T2>(this IDictionary<T1, T2> source, T1 key)
where T2 : new()
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<T1, T2> |
source |
|
T1 |
key |
|
Returns
Type Parameters
GetTypedValue<T>(IDictionary<String, Object>, String)
Returns typed value if it exists, otherwise returns default T
.
Declaration
public static T GetTypedValue<T>(this IDictionary<string, object> source, string key)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<System.String, System.Object> |
source |
Source dictionary.
|
System.String |
key |
Key which value to get.
|
Returns
Type |
Description |
T |
Value or default value of T .
|
Type Parameters
Name |
Description |
T |
The type to be casted to.
|
Exceptions
Type |
Condition |
System.ArgumentNullException |
source is null.
|
GetValue<T>(IDictionary<String, Object>, String, T)
Declaration
public static T GetValue<T>(this IDictionary<string, object> source, string key, T defValue)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<System.String, System.Object> |
source |
|
System.String |
key |
|
T |
defValue |
|
Returns
Type Parameters
GetValueOrDefault<K, V>(IDictionary<K, V>, K, V)
Gets value from dictionary. If no value found then returns defValue
.
Declaration
public static V GetValueOrDefault<K, V>(this IDictionary<K, V> source, K key, V defValue)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<K, V> |
source |
Source dictionary.
|
K |
key |
Key which value to get.
|
V |
defValue |
Default value.
|
Returns
Type |
Description |
V |
Value from dictionary or default value.
|
Type Parameters
Name |
Description |
K |
Type of keys in dictionary.
|
V |
Type of values in dictionary.
|
ToObject<T>(IDictionary<String, Object>)
Declaration
public static T ToObject<T>(this IDictionary<string, object> source)
where T : class, new()
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<System.String, System.Object> |
source |
|
Returns
Type Parameters