/// <summary> /// Adds an entry with the specified <paramref name="key"/> and <paramref name="value"/>. An exception is thrown in an entry already exists. /// </summary> /// <param name="collection">The collection to add the entry to.</param> /// <param name="key">The key of the entry to add.</param> /// <param name="value">The value to add.</param> /// <exception cref="InvalidOperationException">Thrown if an entry with the specified <paramref name="key"/> already exists.</exception> public static void Add <TKey, TValue>(this IReactiveEntityCollection <TKey, TValue> collection, TKey key, TValue value) { if (!collection.TryAdd(key, value)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "An entry with key '{0}' already exists.", key)); } }
public bool TryAdd(TKey key, TValue value) { _blockAdd.WaitOne(); return(_inner.TryAdd(key, value)); }
public bool TryAdd(TKey key, TValue value) => _local.TryAdd(key, value);