TryAdd Method
Definition
- Namespace
- Cuemon.Collections.Generic
- Assemblies
- Cuemon.Core.dll
TryAdd<TKey, TValue>(IDecorator<IDictionary<TKey, TValue>>, TKey, TValue, Func<IDictionary<TKey, TValue>, bool>)
Attempts to add the specified key and value to the enclosed IDictionary<TKey, TValue> of the decorator.
public static bool TryAdd<TKey, TValue>(this IDecorator<IDictionary<TKey, TValue>> decorator, TKey key, TValue value, Func<IDictionary<TKey, TValue>, bool> condition)
Parameters
decoratorIDecorator<IDictionary<TKey, TValue>>The IDecorator<T> to extend.
keyTKeyThe key of the element to add.
valueTValueThe value of the element to add.
conditionFunc<IDictionary<TKey, TValue>, bool>The function delegate that specifies the condition for adding the element.
Returns
- bool
trueif the key/value pair was added to the enclosed IDictionary<TKey, TValue> of thedecoratorsuccessfully; otherwise,false.
Type Parameters
TKeyThe type of the keys in the dictionary.
TValueThe type of the values in the dictionary.
Exceptions
- ArgumentNullException
decoratorcannot be null -or-keycannot be null -or-conditioncannot be null.
TryAdd<TKey, TValue>(IDecorator<IDictionary<TKey, TValue>>, TKey, TValue)
Attempts to add the specified key and value to the enclosed IDictionary<TKey, TValue> of the decorator.
public static bool TryAdd<TKey, TValue>(this IDecorator<IDictionary<TKey, TValue>> decorator, TKey key, TValue value)
Parameters
decoratorIDecorator<IDictionary<TKey, TValue>>The IDecorator<T> to extend.
keyTKeyThe key of the element to add.
valueTValueThe value of the element to add.
Returns
- bool
trueif the key/value pair was added to the enclosed IDictionary<TKey, TValue> of thedecoratorsuccessfully; otherwise,false.
Type Parameters
TKeyThe type of the keys in the dictionary.
TValueThe type of the values in the dictionary.
Exceptions
- ArgumentNullException
decoratorcannot be null -or-keycannot be null.