using System.Collections.Generic;
namespace MediaBrowser.Installer.Code
{
///
/// Class ModelExtensions
///
static class ModelExtensions
{
///
/// Values the or default.
///
/// The STR.
/// The def.
/// System.String.
public static string ValueOrDefault(this string str, string def = "")
{
return string.IsNullOrEmpty(str) ? def : str;
}
///
/// Helper method for Dictionaries since they throw on not-found keys
///
///
///
/// The dictionary.
/// The key.
/// The default value.
/// ``1.
public static U GetValueOrDefault(this Dictionary dictionary, T key, U defaultValue)
{
U val;
if (!dictionary.TryGetValue(key, out val))
{
val = defaultValue;
}
return val;
}
}
}