От: | -n1l- | ||
Дата: | 29.04.16 14:48 | ||
Оценка: |
public static TResult GetValue<TKey, TValue, TResult>(this IDictionary<TKey, TValue> source,
TKey key,
Func<TValue, TResult> callback,
Func<TKey, TResult> callbackIfEmpty)
{
if (!source.ContainsKey(key))
{
return callbackIfEmpty(key);
}
var result = source[key];
return callback(result);
}