mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-27 06:02:33 +01: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:
parent
057829c3b0
commit
b5b43b8b3f
@ -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)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -1,23 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NLog;
|
||||
using FluentValidation.Results;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Deluge
|
||||
{
|
||||
// this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
public class Deluge : TorrentClientBase<DelugeSettings>
|
||||
{
|
||||
private readonly IDelugeProxy _proxy;
|
||||
|
@ -12,7 +12,7 @@ public interface IHadoukenProxy
|
||||
{
|
||||
HadoukenSystemInfo GetSystemInfo(HadoukenSettings settings);
|
||||
HadoukenTorrent[] GetTorrents(HadoukenSettings settings);
|
||||
IDictionary<string, object> GetConfig(HadoukenSettings settings);
|
||||
IReadOnlyDictionary<string, object> GetConfig(HadoukenSettings settings);
|
||||
string AddTorrentFile(HadoukenSettings settings, byte[] fileContent);
|
||||
void AddTorrentUri(HadoukenSettings settings, string torrentUrl);
|
||||
void RemoveTorrent(HadoukenSettings settings, string downloadId);
|
||||
@ -42,9 +42,9 @@ public HadoukenTorrent[] GetTorrents(HadoukenSettings settings)
|
||||
return GetTorrents(result.Torrents);
|
||||
}
|
||||
|
||||
public IDictionary<string, object> GetConfig(HadoukenSettings settings)
|
||||
public IReadOnlyDictionary<string, object> GetConfig(HadoukenSettings settings)
|
||||
{
|
||||
return ProcessRequest<IDictionary<string, object>>(settings, "webui.getSettings");
|
||||
return ProcessRequest<IReadOnlyDictionary<string, object>>(settings, "webui.getSettings");
|
||||
}
|
||||
|
||||
public string AddTorrentFile(HadoukenSettings settings, byte[] fileContent)
|
||||
|
@ -6,6 +6,7 @@
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
@ -16,9 +17,6 @@
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
{
|
||||
// this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
public class Nzbget : UsenetClientBase<NzbgetSettings>
|
||||
{
|
||||
private readonly INzbgetProxy _proxy;
|
||||
|
@ -311,7 +311,7 @@ private void AddQualityTokens(Dictionary<string, Func<TokenMatch, string>> token
|
||||
}
|
||||
|
||||
private const string MediaInfoVideoDynamicRangeToken = "{MediaInfo VideoDynamicRange}";
|
||||
private static readonly IDictionary<string, int> MinimumMediaInfoSchemaRevisions =
|
||||
private static readonly IReadOnlyDictionary<string, int> MinimumMediaInfoSchemaRevisions =
|
||||
new Dictionary<string, int>(FileNameBuilderTokenEqualityComparer.Instance)
|
||||
{
|
||||
{MediaInfoVideoDynamicRangeToken, 5}
|
||||
|
@ -27,7 +27,7 @@ public class ParsedMovieInfo
|
||||
/// It is expanded by the augmenters.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public IDictionary<string, object> ExtraInfo = new Dictionary<string, object>();
|
||||
public Dictionary<string, object> ExtraInfo = new Dictionary<string, object>();
|
||||
public List<Language> Languages = new List<Language>();
|
||||
public string ReleaseGroup { get; set; }
|
||||
public string ReleaseHash { get; set; }
|
||||
|
@ -5,12 +5,10 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Mono.Disk
|
||||
{
|
||||
// this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
public interface IProcMountProvider
|
||||
{
|
||||
List<IMount> GetMounts();
|
||||
|
@ -6,7 +6,6 @@
|
||||
using Nancy.Bootstrapper;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace Radarr.Http.Extensions.Pipelines
|
||||
{
|
||||
@ -81,7 +80,7 @@ private static void WriteGZipStream(Action<Stream> innerContent, Stream targetSt
|
||||
|
||||
private static bool ContentLengthIsTooSmall(Response response)
|
||||
{
|
||||
var contentLength = response.Headers.GetValueOrDefault("Content-Length");
|
||||
var contentLength = response.Headers.TryGetValue("Content-Length", out var value) ? value : null;
|
||||
|
||||
if (contentLength != null && long.Parse(contentLength) < 1024)
|
||||
{
|
||||
@ -93,7 +92,7 @@ private static bool ContentLengthIsTooSmall(Response response)
|
||||
|
||||
private static bool AlreadyGzipEncoded(Response response)
|
||||
{
|
||||
var contentEncoding = response.Headers.GetValueOrDefault("Content-Encoding");
|
||||
var contentEncoding = response.Headers.TryGetValue("Content-Encoding", out var value) ? value : null;
|
||||
|
||||
if (contentEncoding == "gzip")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user