aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Extensions/CollectionExtensions.cs
diff options
context:
space:
mode:
authorClaus Vium <clausvium@gmail.com>2019-03-05 10:27:25 +0100
committerClaus Vium <clausvium@gmail.com>2019-03-05 10:27:25 +0100
commit318e0d4a2449baff806afb4ee22dc0f4021ca180 (patch)
treeea8d4a92ea38b22d72cecbd2a37b0e9fdebf2fd6 /MediaBrowser.Common/Extensions/CollectionExtensions.cs
parentbc00617df7eee51a80302816bef9a797455e7780 (diff)
Add GetValueOrDefault dictionary extension
Diffstat (limited to 'MediaBrowser.Common/Extensions/CollectionExtensions.cs')
-rw-r--r--MediaBrowser.Common/Extensions/CollectionExtensions.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Extensions/CollectionExtensions.cs b/MediaBrowser.Common/Extensions/CollectionExtensions.cs
new file mode 100644
index 000000000..f7c0e3cf0
--- /dev/null
+++ b/MediaBrowser.Common/Extensions/CollectionExtensions.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+
+namespace MediaBrowser.Common.Extensions
+{
+ // The MS CollectionExtensions are only available in netcoreapp
+ public static class CollectionExtensions
+ {
+ public static TValue GetValueOrDefault<TKey, TValue> (this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
+ {
+ dictionary.TryGetValue(key, out var ret);
+ return ret;
+ }
+ }
+}