aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Installer/Code/ModelExtensions.cs
diff options
context:
space:
mode:
authorEric Reed <ebr@mediabrowser3.com>2013-02-25 20:11:51 -0500
committerEric Reed <ebr@mediabrowser3.com>2013-02-25 20:12:08 -0500
commit844121acc96f0280d9f527175e56e77b4dac8d71 (patch)
treeafb4d68e73f8f41516188062e34968fd8bd2c74d /MediaBrowser.Installer/Code/ModelExtensions.cs
parent9f485c244f9adeeb669abc6361ed1a0e3ec7bb15 (diff)
More uninstaller/installer incrementals
Gonna need separate installers for server and mbt due to CO limitations
Diffstat (limited to 'MediaBrowser.Installer/Code/ModelExtensions.cs')
-rw-r--r--MediaBrowser.Installer/Code/ModelExtensions.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/MediaBrowser.Installer/Code/ModelExtensions.cs b/MediaBrowser.Installer/Code/ModelExtensions.cs
index 5a3051164..66e51ec11 100644
--- a/MediaBrowser.Installer/Code/ModelExtensions.cs
+++ b/MediaBrowser.Installer/Code/ModelExtensions.cs
@@ -1,4 +1,6 @@

+using System.Collections.Generic;
+
namespace MediaBrowser.Installer.Code
{
/// <summary>
@@ -16,5 +18,26 @@ namespace MediaBrowser.Installer.Code
{
return string.IsNullOrEmpty(str) ? def : str;
}
+
+ /// <summary>
+ /// Helper method for Dictionaries since they throw on not-found keys
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <typeparam name="U"></typeparam>
+ /// <param name="dictionary">The dictionary.</param>
+ /// <param name="key">The key.</param>
+ /// <param name="defaultValue">The default value.</param>
+ /// <returns>``1.</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;
+
+ }
+
}
}