mirror of
https://github.com/kevincolyar/CronNET.git
synced 2026-03-04 04:29:05 +01:00
Added IoC interfaces. Nuget auto restore
Added interfaces to allow injection and mocking. Setup test to use nuget packages to allow easier setup
This commit is contained in:
@@ -5,10 +5,17 @@ using System.Threading;
|
||||
|
||||
namespace CronNET
|
||||
{
|
||||
public class CronDaemon
|
||||
public interface ICronDaemon
|
||||
{
|
||||
void AddJob(string schedule, ThreadStart action);
|
||||
void Start();
|
||||
void Stop();
|
||||
}
|
||||
|
||||
public class CronDaemon : ICronDaemon
|
||||
{
|
||||
private readonly System.Timers.Timer timer = new System.Timers.Timer(30000);
|
||||
private readonly List<CronJob> cron_jobs = new List<CronJob>();
|
||||
private readonly List<ICronJob> cron_jobs = new List<ICronJob>();
|
||||
private DateTime _last= DateTime.Now;
|
||||
|
||||
public CronDaemon()
|
||||
@@ -41,7 +48,7 @@ namespace CronNET
|
||||
if (DateTime.Now.Minute != _last.Minute)
|
||||
{
|
||||
_last = DateTime.Now;
|
||||
foreach (CronJob job in cron_jobs)
|
||||
foreach (ICronJob job in cron_jobs)
|
||||
job.execute(DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user