diff options
| author | ebr11 Eric Reed spam <ebr11 Eric Reed spam@reedsplace.com> | 2012-09-18 15:18:15 -0400 |
|---|---|---|
| committer | ebr11 Eric Reed spam <ebr11 Eric Reed spam@reedsplace.com> | 2012-09-18 15:18:15 -0400 |
| commit | 0f078d8098e60804c4f9b13c82566286362a83f2 (patch) | |
| tree | 6b6ff327bf79c865daab446f8f811604ab01c2da /MediaBrowser.Common/Extensions | |
| parent | e5b5861abf1ebd940e9b369de3cd3ab0432338c5 (diff) | |
Move NeedsRefresh to async task and fix problem finding episode metadata
Diffstat (limited to 'MediaBrowser.Common/Extensions')
| -rw-r--r-- | MediaBrowser.Common/Extensions/BaseExtensions.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs index ceb008629..10ff019aa 100644 --- a/MediaBrowser.Common/Extensions/BaseExtensions.cs +++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs @@ -36,5 +36,26 @@ namespace MediaBrowser.Common.Extensions }
return false;
}
+
+ /// <summary>
+ /// Helper method for Dictionaries since they throw on not-found keys
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <typeparam name="U"></typeparam>
+ /// <param name="dictionary"></param>
+ /// <param name="key"></param>
+ /// <param name="defaultValue"></param>
+ /// <returns></returns>
+ public static U GetValueOrDefault<T, U>(this Dictionary<T, U> dictionary, T key, U defaultValue)
+ {
+ U val;
+ if (!dictionary.TryGetValue(key, out val))
+ {
+ val = defaultValue;
+ }
+ return val;
+
+ }
+
}
}
|
