diff --git a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs index 85fcb86..41bbb8e 100644 --- a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs +++ b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs @@ -7,6 +7,22 @@ namespace ICD.Common.Utils.Extensions { public static class DictionaryExtensions { + /// + /// Removes all of the given keys from the dictionary. + /// + /// + /// + /// + /// + public static void RemoveAll(this IDictionary extends, IEnumerable keys) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + foreach (TKey key in keys) + extends.Remove(key); + } + /// /// Removes the first key with a value matching the given value. /// @@ -22,10 +38,7 @@ namespace ICD.Common.Utils.Extensions throw new ArgumentNullException("extends"); TKey key; - if (!extends.TryGetKey(value, out key)) - return false; - - return extends.Remove(key); + return extends.TryGetKey(value, out key) && extends.Remove(key); } ///