1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-02-26 08:02:56 +00:00
Radarr/src/NzbDrone.Common/DictionaryExtensions.cs
Mark McDowall e21574a203 Blacklisting improvements
New: New releases that fail will be retried a second time after waiting 1hr (configurable)
Fixed: Blacklisting releases with the same date and vastly different ages
2014-04-08 17:19:36 -07:00

27 lines
940 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Common
{
public static class DictionaryExtensions
{
public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue))
{
TValue value;
return dictionary.TryGetValue(key, out value) ? value : defaultValue;
}
public static Dictionary<T1, T2> Merge<T1, T2>(this Dictionary<T1, T2> first, Dictionary<T1, T2> second)
{
if (first == null) throw new ArgumentNullException("first");
if (second == null) throw new ArgumentNullException("second");
var merged = new Dictionary<T1, T2>();
first.ToList().ForEach(kv => merged[kv.Key] = kv.Value);
second.ToList().ForEach(kv => merged[kv.Key] = kv.Value);
return merged;
}
}
}