TryGetValueOrFallback Method
Definition
- Namespace
- Cuemon.Collections.Generic
- Assemblies
- Cuemon.Core.dll
TryGetValueOrFallback<TKey, TValue>(IDecorator<IDictionary<TKey, TValue>>, TKey, Func<IEnumerable<TKey>, TKey>, out TValue)
Gets the value associated with the specified key from the enclosed IDictionary<TKey, TValue> of the decorator.
public static bool TryGetValueOrFallback<TKey, TValue>(this IDecorator<IDictionary<TKey, TValue>> decorator, TKey key, Func<IEnumerable<TKey>, TKey> fallbackKeySelector, out TValue value)
Parameters
decoratorIDecorator<IDictionary<TKey, TValue>>The IDecorator<T> to extend.
keyTKeyThe key of the value to get.
fallbackKeySelectorFunc<IEnumerable<TKey>, TKey>The function delegate that will, as a fallback, resolve an alternate key from the specified
key.valueTValueWhen this method returns, contains the value associated with the specified
keyor the alternate key resolved fromfallbackKeySelector, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Returns
- bool
trueif the enclosed IDictionary<TKey, TValue> of thedecoratorcontains an element with the specifiedkeyor the alternate key resolved fromfallbackKeySelector,falseotherwise.
Type Parameters
TKeyThe type of the keys in the dictionary.
TValueThe type of the values in the dictionary.
Exceptions
- ArgumentNullException
decoratorcannot be null.