1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

Ninject is now forced to use proper constructor.

This commit is contained in:
kay.one 2011-06-13 18:23:04 -07:00
parent 5293d0e204
commit add780b431
34 changed files with 88 additions and 53 deletions

View File

@ -86,7 +86,6 @@ public static void BindKernel()
_kernel.Bind<ExternalNotificationProvider>().ToSelf().InSingletonScope();
_kernel.Bind<XbmcProvider>().ToSelf().InSingletonScope();
_kernel.Bind<ConfigProvider>().To<ConfigProvider>().InSingletonScope();
_kernel.Bind<SyncProvider>().ToSelf().InSingletonScope();
_kernel.Bind<NotificationProvider>().ToSelf().InSingletonScope();
_kernel.Bind<LogProvider>().ToSelf().InSingletonScope();
_kernel.Bind<MediaFileProvider>().ToSelf().InSingletonScope();

View File

@ -13,9 +13,6 @@ namespace NzbDrone.Core.Providers
{
public class AutoConfigureProvider
{
public AutoConfigureProvider()
{
}
public SabnzbdInfoModel AutoConfigureSab()
{
@ -29,8 +26,7 @@ private List<ConnectionInfoModel> GetConnectionList()
var info =
ipProperties.GetActiveTcpListeners().Select(
p =>
new ConnectionInfoModel
{Address = p.Address.ToString().Replace("0.0.0.0", "127.0.0.1"), Port = p.Port}).Distinct().
new ConnectionInfoModel { Address = p.Address.ToString().Replace("0.0.0.0", "127.0.0.1"), Port = p.Port }).Distinct().
ToList();
info.RemoveAll(i => i.Port == 135);
@ -51,7 +47,8 @@ private SabnzbdInfoModel FindApiKey(List<ConnectionInfoModel> info)
{
var apiKey = GetApiKey(connection.Address, connection.Port);
if (!String.IsNullOrEmpty(apiKey))
return new SabnzbdInfoModel {
return new SabnzbdInfoModel
{
Host = connection.Address,
Port = connection.Port,
ApiKey = apiKey

View File

@ -1,19 +0,0 @@
using System;
namespace NzbDrone.Core.Providers
{
public class BacklogProvider
{
//Will provide Backlog Search functionality
public virtual bool StartSearch()
{
throw new NotImplementedException();
}
public virtual bool StartSearch(int seriesId)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
@ -13,6 +14,7 @@ public class ConfigProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _repository;
[Inject]
public ConfigProvider(IRepository repository)
{
_repository = repository;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -17,6 +18,7 @@ public class DownloadProvider
private readonly EpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public DownloadProvider(SabProvider sabProvider, HistoryProvider historyProvider, EpisodeProvider episodeProvider)
{
_sabProvider = sabProvider;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
@ -16,6 +17,7 @@ public class ExternalNotificationProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _repository;
[Inject]
public ExternalNotificationProvider(IRepository repository)
{
_repository = repository;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
@ -14,6 +15,7 @@ public class HistoryProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _repository;
[Inject]
public HistoryProvider(IRepository repository)
{
_repository = repository;

View File

@ -3,6 +3,7 @@
using System.Net;
using System.ServiceModel.Syndication;
using System.Web;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -15,6 +16,7 @@ public abstract class IndexerBase
private readonly HttpProvider _httpProvider;
protected readonly ConfigProvider _configProvider;
[Inject]
protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider)
{
_httpProvider = httpProvider;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
@ -10,6 +11,7 @@ namespace NzbDrone.Core.Providers.Indexer
{
public class Newzbin : IndexerBase
{
[Inject]
public Newzbin(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
@ -11,6 +12,7 @@ namespace NzbDrone.Core.Providers.Indexer
{
public class NzbMatrix : IndexerBase
{
[Inject]
public NzbMatrix(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
{
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
@ -11,6 +12,7 @@ namespace NzbDrone.Core.Providers.Indexer
{
public class NzbsOrg : IndexerBase
{
[Inject]
public NzbsOrg(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
{

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
@ -10,6 +11,7 @@ namespace NzbDrone.Core.Providers.Indexer
{
public class NzbsRUs : IndexerBase
{
[Inject]
public NzbsRUs(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider)
{
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
@ -15,6 +16,7 @@ public class IndexerProvider
private IList<IndexerBase> _indexers = new List<IndexerBase>();
[Inject]
public IndexerProvider(IRepository repository)
{
_repository = repository;

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
@ -15,6 +16,7 @@ public class InventoryProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public InventoryProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, HistoryProvider historyProvider)
{
_seriesProvider = seriesProvider;

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
@ -14,6 +15,7 @@ public class DeleteSeriesJob : IJob
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public DeleteSeriesJob(SeriesProvider seriesProvider)
{
_seriesProvider = seriesProvider;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
@ -14,6 +15,7 @@ public class DiskScanJob : IJob
private readonly MediaFileProvider _mediaFileProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public DiskScanJob(SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider)
{
_seriesProvider = seriesProvider;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
@ -20,6 +21,7 @@ public class EpisodeSearchJob : IJob
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public EpisodeSearchJob(InventoryProvider inventoryProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider, EpisodeProvider episodeProvider)
{
_inventoryProvider = inventoryProvider;
@ -44,7 +46,7 @@ public void Start(ProgressNotification notification, int targetId)
throw new ArgumentOutOfRangeException("targetId");
var episode = _episodeProvider.GetEpisode(targetId);
if (episode == null)
{
Logger.Error("Unable to find an episode {0} in database", targetId);
@ -58,7 +60,7 @@ public void Start(ProgressNotification notification, int targetId)
var title = SceneNameHelper.GetTitleById(series.SeriesId);
if(string.IsNullOrWhiteSpace(title))
if (string.IsNullOrWhiteSpace(title))
{
title = series.Title;
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
@ -23,12 +24,13 @@ public class ImportNewSeriesJob : IJob
private List<int> _attemptedSeries;
[Inject]
public ImportNewSeriesJob(SeriesProvider seriesProvider,
MediaFileProvider mediaFileProvider, UpdateInfoJob updateInfoJob, DiskScanJob diskScanJob)
{
_seriesProvider = seriesProvider;
_mediaFileProvider = mediaFileProvider;
_updateInfoJob = updateInfoJob;
_updateInfoJob = updateInfoJob;
_diskScanJob = diskScanJob;
}
@ -91,22 +93,22 @@ private void AutoIgnoreSeasons(Series updatedSeries)
foreach (var season in seasons)
{
if (season!=currentSeasons )
if (season != currentSeasons)
{
}
}
/* Logger.Debug("Looking for seasons to ignore");
foreach (var season in updatedSeries.Seasons)
{
if (season.SeasonNumber != updatedSeries.Seasons.Max(s => s.SeasonNumber) && _mediaFileProvider.GetSeasonFiles(season.SeasonId).Count() == 0)
{
Logger.Info("Season {0} of {1} doesn't have any files on disk. season will not be monitored.", season.SeasonNumber, updatedSeries.Title);
season.Monitored = false;
_seasonProvider.SaveSeason(season);
}
}*/
/* Logger.Debug("Looking for seasons to ignore");
foreach (var season in updatedSeries.Seasons)
{
if (season.SeasonNumber != updatedSeries.Seasons.Max(s => s.SeasonNumber) && _mediaFileProvider.GetSeasonFiles(season.SeasonId).Count() == 0)
{
Logger.Info("Season {0} of {1} doesn't have any files on disk. season will not be monitored.", season.SeasonNumber, updatedSeries.Title);
season.Monitored = false;
_seasonProvider.SaveSeason(season);
}
}*/
}
}
}

View File

@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
@ -24,6 +25,7 @@ public class JobProvider
private ProgressNotification _notification;
[Inject]
public JobProvider(IRepository repository, NotificationProvider notificationProvider, IList<IJob> jobs)
{
_repository = repository;

View File

@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Text;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
@ -18,6 +19,7 @@ public class PostDownloadScanJob : IJob
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public PostDownloadScanJob(ConfigProvider configProvider, DiskProvider diskProvider,
MediaFileProvider mediaFileProvider, SeriesProvider seriesProvider)
{

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
@ -16,6 +17,7 @@ public class RenameEpisodeJob : IJob
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public RenameEpisodeJob(DiskProvider diskProvider, EpisodeProvider episodeProvider,
MediaFileProvider mediaFileProvider, SeriesProvider seriesProvider)
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
@ -18,6 +19,7 @@ public class RssSyncJob : IJob
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public RssSyncJob(IEnumerable<IndexerBase> indexers, InventoryProvider inventoryProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider)
{
_indexers = indexers;

View File

@ -1,5 +1,6 @@
using System.Linq;
using System.Collections.Generic;
using Ninject;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
@ -10,6 +11,7 @@ public class UpdateInfoJob : IJob
private readonly SeriesProvider _seriesProvider;
private readonly EpisodeProvider _episodeProvider;
[Inject]
public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider)
{
_seriesProvider = seriesProvider;
@ -18,7 +20,7 @@ public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvi
public UpdateInfoJob()
{
}
public string Name

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification;
@ -22,6 +23,7 @@ public class MediaFileProvider
private readonly IRepository _repository;
private readonly ConfigProvider _configProvider;
[Inject]
public MediaFileProvider(IRepository repository, DiskProvider diskProvider,
EpisodeProvider episodeProvider, SeriesProvider seriesProvider,
ConfigProvider configProvider)

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
@ -16,6 +17,7 @@ public QualityProvider()
{
}
[Inject]
public QualityProvider(IRepository repository)
{
_repository = repository;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
@ -16,7 +17,7 @@ public class RootDirProvider
private readonly DiskProvider _diskProvider;
private readonly SeriesProvider _seriesProvider;
[Inject]
public RootDirProvider(IRepository repository, SeriesProvider seriesProvider, DiskProvider diskProvider)
{
_repository = repository;

View File

@ -5,6 +5,7 @@
using System.Text.RegularExpressions;
using System.Web;
using System.Xml.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
@ -21,6 +22,7 @@ public SabProvider()
{
}
[Inject]
public SabProvider(ConfigProvider configProvider, HttpProvider httpProvider)
{
_configProvider = configProvider;

View File

@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
@ -15,14 +16,12 @@ namespace NzbDrone.Core.Providers
{
public class SeriesProvider
{
//TODO: Remove parsing of rest of tv show info we just need the show name
//Trims all white spaces and separators from the end of the title.
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _repository;
private readonly ConfigProvider _configProvider;
private readonly TvDbProvider _tvDbProvider;
[Inject]
public SeriesProvider(ConfigProvider configProviderProvider, IRepository repository, TvDbProvider tvDbProviderProvider)
{
_configProvider = configProviderProvider;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
namespace NzbDrone.Core.Providers
{
@ -9,6 +10,7 @@ public class StatsProvider
{
private readonly SeriesProvider _seriesProvider;
[Inject]
public StatsProvider(SeriesProvider seriesProvider)
{
_seriesProvider = seriesProvider;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
@ -11,6 +12,7 @@ public class UpcomingEpisodesProvider
{
private readonly IRepository _repository;
[Inject]
public UpcomingEpisodesProvider(IRepository repository)
{
_repository = repository;
@ -26,7 +28,7 @@ public virtual UpcomingEpisodesModel Upcoming()
var today = allEps.Where(e => e.AirDate == DateTime.Today).ToList();
var week = allEps.Where(e => e.AirDate > DateTime.Today).ToList();
return new UpcomingEpisodesModel {Yesterday = yesterday, Today = today, Week = week};
return new UpcomingEpisodesModel { Yesterday = yesterday, Today = today, Week = week };
}
public virtual List<Episode> Yesterday()

View File

@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
@ -14,6 +15,7 @@ public class XbmcProvider
private readonly ConfigProvider _configProvider;
private readonly HttpProvider _httpProvider;
[Inject]
public XbmcProvider(ConfigProvider configProvider, HttpProvider httpProvider)
{
_configProvider = configProvider;

View File

@ -21,17 +21,16 @@ public class AddSeriesController : Controller
private readonly RootDirProvider _rootFolderProvider;
private readonly SeriesProvider _seriesProvider;
private readonly JobProvider _jobProvider;
private readonly SyncProvider _syncProvider;
private readonly TvDbProvider _tvDbProvider;
private readonly DiskProvider _diskProvider;
public AddSeriesController(SyncProvider syncProvider, RootDirProvider rootFolderProvider,
public AddSeriesController(RootDirProvider rootFolderProvider,
ConfigProvider configProvider,
QualityProvider qualityProvider, TvDbProvider tvDbProvider,
SeriesProvider seriesProvider, JobProvider jobProvider,
DiskProvider diskProvider)
{
_syncProvider = syncProvider;
_rootFolderProvider = rootFolderProvider;
_configProvider = configProvider;
_qualityProvider = qualityProvider;
@ -50,7 +49,7 @@ public JsonResult ScanNewSeries()
public ActionResult AddNew()
{
var rootDirs =_rootFolderProvider.GetAll().Select(r =>
var rootDirs = _rootFolderProvider.GetAll().Select(r =>
new RootDirModel
{
Path = r.Path,
@ -137,10 +136,10 @@ public JsonResult AddNewSeries(string rootPath, string seriesName, int seriesId,
_seriesProvider.AddSeries(path, seriesId, qualityProfileId);
ScanNewSeries();
return new JsonResult {Data = "ok"};
return new JsonResult { Data = "ok" };
}
catch(Exception ex)
catch (Exception ex)
{
return new JsonResult { Data = "failed" };
}

View File

@ -1,4 +1,5 @@
using System.Web.Mvc;
using MvcMiniProfiler;
using NzbDrone.Core.Providers;
namespace NzbDrone.Web.Controllers
@ -35,6 +36,12 @@ public JsonResult Index()
message = _notifications.GetProgressNotifications[0].CurrentMessage;
}
if (MiniProfiler.Current.DurationMilliseconds < 100)
{
MiniProfiler.Stop(true);
}
return Json(message, JsonRequestBehavior.AllowGet);
}
}