diff --git a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs
index 33db000..7e6f258 100644
--- a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs
+++ b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs
@@ -7,6 +7,29 @@ namespace ICD.Common.Utils.Extensions
{
public static class DictionaryExtensions
{
+ ///
+ /// Removes the key from the dictionary, outputting the value.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool Remove([NotNull] this IDictionary extends,
+ [NotNull] TKey key, out TValue value)
+ {
+ if (extends == null)
+ throw new ArgumentNullException("extends");
+
+// ReSharper disable CompareNonConstrainedGenericWithNull
+ if (key == null)
+// ReSharper restore CompareNonConstrainedGenericWithNull
+ throw new ArgumentNullException("key");
+
+ return extends.TryGetValue(key, out value) && extends.Remove(key);
+ }
+
///
/// Removes all of the given keys from the dictionary.
///
@@ -78,7 +101,9 @@ namespace ICD.Common.Utils.Extensions
if (extends == null)
throw new ArgumentNullException("extends");
+// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
+// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
return extends.GetDefault(key, default(TValue));
@@ -101,7 +126,9 @@ namespace ICD.Common.Utils.Extensions
if (extends == null)
throw new ArgumentNullException("extends");
+// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
+// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
TValue value;
@@ -119,13 +146,14 @@ namespace ICD.Common.Utils.Extensions
///
[PublicAPI]
public static TValue GetOrAddDefault([NotNull] this IDictionary extends,
- [NotNull] TKey key,
- TValue defaultValue)
+ [NotNull] TKey key, TValue defaultValue)
{
if (extends == null)
throw new ArgumentNullException("extends");
+// ReSharper disable CompareNonConstrainedGenericWithNull
if (key == null)
+// ReSharper restore CompareNonConstrainedGenericWithNull
throw new ArgumentNullException("key");
TValue value = extends.GetDefault(key, defaultValue);