namespace VideoBrowser.Extensions
{
using System.Collections.Generic;
using System.Collections.Specialized;
///
/// Defines the
///
public static class DictionaryExtensions
{
#region Methods
///
/// The Get
///
///
///
/// The dictionary
/// The key
/// The defaultValue
/// The
public static TValue Get(this Dictionary dictionary, TKey key, TValue defaultValue)
{
if (!dictionary.ContainsKey(key))
{
dictionary.Add(key, defaultValue);
}
return dictionary[key];
}
///
/// The Get
///
///
/// The dictionary
/// The key
/// The defaultValue
/// The
public static TValue Get(this OrderedDictionary dictionary, object key, object defaultValue)
{
if (!dictionary.Contains(key))
{
dictionary.Add(key, defaultValue);
}
return (TValue)dictionary[key];
}
///
/// The Put
///
///
///
/// The dictionary
/// The key
/// The value
public static void Put(this Dictionary dictionary, TKey key, TValue value)
{
if (dictionary.ContainsKey(key))
{
dictionary[key] = value;
}
else
{
dictionary.Add(key, value);
}
}
///
/// The Put
///
/// The dictionary
/// The key
/// The value
public static void Put(this OrderedDictionary dictionary, object key, object value)
{
if (dictionary.Contains(key))
{
dictionary[key] = value;
}
else
{
dictionary.Add(key, value);
}
}
#endregion Methods
}
}