mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-22 22:34:53 -04:00
Changed: Align GetValueOrDefault extension with netcore3.0 version
- netcore3.0 implements the extenion on IReadOnlyDictionary. - Dictionary implements both IReadonlyDictionary and IDictionary and so defining the extenion on both interfaces creates an ambiguous reference - IDictionary doesn't inherit from IReadOnlyDictionary Either we have to add 'using NzbDrone.Common.Extenions;' separately to resolve the ambiguity or we have to standardaize on only having the extension on IReadOnlyDictionary.
This commit is contained in:
@@ -6,11 +6,13 @@ namespace NzbDrone.Common.Extensions
|
||||
{
|
||||
public static class DictionaryExtensions
|
||||
{
|
||||
public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue))
|
||||
#if !NETCOREAPP3_0
|
||||
public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue))
|
||||
{
|
||||
TValue value;
|
||||
return dictionary.TryGetValue(key, out value) ? value : defaultValue;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static Dictionary<T1, T2> Merge<T1, T2>(this Dictionary<T1, T2> first, Dictionary<T1, T2> second)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user