diff --git a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs index 41bbb8e..1e5766b 100644 --- a/ICD.Common.Utils/Extensions/DictionaryExtensions.cs +++ b/ICD.Common.Utils/Extensions/DictionaryExtensions.cs @@ -386,5 +386,21 @@ namespace ICD.Common.Utils.Extensions return extends.OrderByKey().Select(kvp => kvp.Value); } + + /// + /// Returns an inverse mapping of TValue -> TKey. + /// + /// + /// + /// + /// + [PublicAPI] + public static Dictionary ToInverse(this IEnumerable> extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + return extends.ToDictionary(kvp => kvp.Value, kvp => kvp.Key); + } } }