예제 #1
0
        /// <summary>
        /// Clears the key value table.
        /// </summary>
        /// <typeparam name="TKey">The type of the key in the key value table.</typeparam>
        /// <typeparam name="TValue">The type of the value in the key value table.</typeparam>
        /// <param name="table">The key value table.</param>
        public static void Clear <TKey, TValue>(this ITransactedKeyValueTable <TKey, TValue> table)
        {
            if (table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            var lst = table.ToList();

            foreach (var item in lst)
            {
                table.Remove(item.Key);
            }
        }
예제 #2
0
        /// <summary>
        /// Removes the value if the the key exists.
        /// </summary>
        /// <typeparam name="TKey">The type of the key in the key value table.</typeparam>
        /// <typeparam name="TValue">The type of the value in the key value table.</typeparam>
        /// <param name="table">The key value table.</param>
        /// <param name="key">The key to remove.</param>
        /// <returns>True if found, false otherwise.</returns>
        public static bool TryRemove <TKey, TValue>(this ITransactedKeyValueTable <TKey, TValue> table, TKey key)
        {
            if (table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            if (table.Contains(key))
            {
                table.Remove(key);
                return(true);
            }

            return(false);
        }
 public void Remove(string key) => _table.Remove(key);