Removed ITimerProvider

This commit is contained in:
Mark McDowall 2011-04-08 08:20:45 -07:00
parent 8380c25eaf
commit 030c6fb7b7
5 changed files with 21 additions and 41 deletions

View File

@ -78,7 +78,7 @@ namespace NzbDrone.Core
_kernel.Bind<INotificationProvider>().To<NotificationProvider>().InSingletonScope(); _kernel.Bind<INotificationProvider>().To<NotificationProvider>().InSingletonScope();
_kernel.Bind<ILogProvider>().To<LogProvider>().InSingletonScope(); _kernel.Bind<ILogProvider>().To<LogProvider>().InSingletonScope();
_kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>().InSingletonScope(); _kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>().InSingletonScope();
_kernel.Bind<ITimerProvider>().To<TimerProvider>().InSingletonScope(); _kernel.Bind<TimerProvider>().To<TimerProvider>().InSingletonScope();
_kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope(); _kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();
_kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<SubsonicTarget>().InSingletonScope(); _kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<SubsonicTarget>().InSingletonScope();
@ -90,7 +90,7 @@ namespace NzbDrone.Core
//Get the Timers going //Get the Timers going
var config = _kernel.Get<IConfigProvider>(); var config = _kernel.Get<IConfigProvider>();
var timer = _kernel.Get<ITimerProvider>(); var timer = _kernel.Get<TimerProvider>();
timer.SetRssSyncTimer(Convert.ToInt32(config.GetValue("SyncFrequency", "15", true))); timer.SetRssSyncTimer(Convert.ToInt32(config.GetValue("SyncFrequency", "15", true)));
timer.StartRssSyncTimer(); timer.StartRssSyncTimer();
} }

View File

@ -190,7 +190,6 @@
<Compile Include="Providers\IPostProcessingProvider.cs" /> <Compile Include="Providers\IPostProcessingProvider.cs" />
<Compile Include="Providers\IRenameProvider.cs" /> <Compile Include="Providers\IRenameProvider.cs" />
<Compile Include="Providers\IRssSyncProvider.cs" /> <Compile Include="Providers\IRssSyncProvider.cs" />
<Compile Include="Providers\ITimerProvider.cs" />
<Compile Include="Providers\PostProcessingProvider.cs" /> <Compile Include="Providers\PostProcessingProvider.cs" />
<Compile Include="Providers\QualityProvider.cs" /> <Compile Include="Providers\QualityProvider.cs" />
<Compile Include="Providers\RenameProvider.cs" /> <Compile Include="Providers\RenameProvider.cs" />

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Providers
{
public interface ITimerProvider
{
void ResetRssSyncTimer();
void StartRssSyncTimer();
void StopRssSyncTimer();
void SetRssSyncTimer(int minutes);
TimeSpan RssSyncTimeLeft();
DateTime NextRssSyncTime();
void StartMinuteTimer();
void StopMinuteTimer();
}
}

View File

@ -8,7 +8,7 @@ using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class TimerProvider : ITimerProvider public class TimerProvider
{ {
private readonly IRssSyncProvider _rssSyncProvider; private readonly IRssSyncProvider _rssSyncProvider;
private readonly ISeriesProvider _seriesProvider; private readonly ISeriesProvider _seriesProvider;
@ -33,15 +33,15 @@ namespace NzbDrone.Core.Providers
_minuteTimer = new Timer(60000); _minuteTimer = new Timer(60000);
} }
#region ITimerProvider Members #region TimerProvider Members
public void ResetRssSyncTimer() public virtual void ResetRssSyncTimer()
{ {
double interval = _rssSyncTimer.Interval; double interval = _rssSyncTimer.Interval;
_rssSyncTimer.Interval = interval; _rssSyncTimer.Interval = interval;
} }
public void StartRssSyncTimer() public virtual void StartRssSyncTimer()
{ {
if (_rssSyncTimer.Interval < 900000) //If Timer is less than 15 minutes, throw an error! This should also be handled when saving the config, though a user could by-pass it by editing the DB directly... TNO (Trust No One) if (_rssSyncTimer.Interval < 900000) //If Timer is less than 15 minutes, throw an error! This should also be handled when saving the config, though a user could by-pass it by editing the DB directly... TNO (Trust No One)
{ {
@ -53,35 +53,35 @@ namespace NzbDrone.Core.Providers
_rssSyncTimer.Start(); _rssSyncTimer.Start();
_rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval); _rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval);
} }
public void StopRssSyncTimer() public virtual void StopRssSyncTimer()
{ {
_rssSyncTimer.Stop(); _rssSyncTimer.Stop();
} }
public void SetRssSyncTimer(int minutes) public virtual void SetRssSyncTimer(int minutes)
{ {
long ms = minutes * 60 * 1000; long ms = minutes * 60 * 1000;
_rssSyncTimer.Interval = ms; _rssSyncTimer.Interval = ms;
} }
public TimeSpan RssSyncTimeLeft() public virtual TimeSpan RssSyncTimeLeft()
{ {
return _rssSyncNextInterval.Subtract(DateTime.Now); return _rssSyncNextInterval.Subtract(DateTime.Now);
} }
public DateTime NextRssSyncTime() public virtual DateTime NextRssSyncTime()
{ {
return _rssSyncNextInterval; return _rssSyncNextInterval;
} }
public void StartMinuteTimer() public virtual void StartMinuteTimer()
{ {
_minuteTimer.Elapsed += new ElapsedEventHandler(MinuteTimer_Elapsed); _minuteTimer.Elapsed += new ElapsedEventHandler(MinuteTimer_Elapsed);
_minuteTimer.Start(); _minuteTimer.Start();
} }
public void StopMinuteTimer() public virtual void StopMinuteTimer()
{ {
_minuteTimer.Stop(); _minuteTimer.Stop();
} }

View File

@ -9,9 +9,9 @@ namespace NzbDrone.Web.Controllers
{ {
public class SharedController : Controller public class SharedController : Controller
{ {
private ITimerProvider _timerProvider; private TimerProvider _timerProvider;
public SharedController(ITimerProvider timerProvider) public SharedController(TimerProvider timerProvider)
{ {
_timerProvider = timerProvider; _timerProvider = timerProvider;
} }