/// <summary> /// This removes any Primary entries matching a specified key "shallowly". /// That is, it removes it from the top-level Primary dictionary, /// All ancestor Primary dictionaries remain unaffected. /// </summary> /// <remarks>Traking info is also removed.</remarks> /// <param name="key">The key of the entry to be removed.</param> /// <returns>A boolean indicating if the specified entry was found and removed.</returns> public bool RemoveLocal(TKey key) { lock (_syncRoot) { return(LocalEntries.Remove(key)); // Tracking info is also removed. } }
/// <summary> /// This removes a Primary entry matching the specified key "deeply". /// That is, it removes it from the top-level dictionary /// and from all ancestors, if they exist. /// </summary> /// <remarks>Traking info is also removed.</remarks> /// <param name="key">The key of the entry to be removed.</param> /// <returns>A boolean indicating if the specified entry was found and removed.</returns> public bool Remove(TKey key) { lock (_syncRoot) { var found = false; // Remove it from each of the parents (recursively) foreach (var parent in Parents.Where(parent => parent.Remove(key))) // Tracking info is also removed. { found = true; } // finally remove it from the top-level if (LocalEntries.Remove(key)) // Tracking info is also removed. { found = true; } return(found); } }