Table of Contents

TryGetValueOrFallback Method

Definition

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

decorator IDecorator<IDictionary<TKey, TValue>>

The IDecorator<T> to extend.

key TKey

The key of the value to get.

fallbackKeySelector Func<IEnumerable<TKey>, TKey>

The function delegate that will, as a fallback, resolve an alternate key from the specified key.

value TValue

When this method returns, contains the value associated with the specified key or the alternate key resolved from fallbackKeySelector, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

true if the enclosed IDictionary<TKey, TValue> of the decorator contains an element with the specified key or the alternate key resolved from fallbackKeySelector, false otherwise.

Type Parameters

TKey

The type of the keys in the dictionary.

TValue

The type of the values in the dictionary.

Exceptions

ArgumentNullException

decorator cannot be null.