public SynchronizationProfileRunner (
        ISynchronizerFactory synchronizerFactory,
        ISynchronizationReportSink reportSink,
        IFolderChangeWatcherFactory folderChangeWatcherFactory,
        Action ensureSynchronizationContext, 
        ISynchronizationRunLogger runLogger)
    {
      if (synchronizerFactory == null)
        throw new ArgumentNullException (nameof (synchronizerFactory));
      if (reportSink == null)
        throw new ArgumentNullException (nameof (reportSink));
      if (folderChangeWatcherFactory == null)
        throw new ArgumentNullException (nameof (folderChangeWatcherFactory));
      if (ensureSynchronizationContext == null)
        throw new ArgumentNullException (nameof (ensureSynchronizationContext));
      if (runLogger == null)
        throw new ArgumentNullException (nameof (runLogger));

      _synchronizerFactory = synchronizerFactory;
      _reportSink = reportSink;
      _folderChangeWatcherFactory = folderChangeWatcherFactory;
      _ensureSynchronizationContext = ensureSynchronizationContext;
      _runLogger = runLogger;
      // Set to min, to ensure that it runs on the first run after startup
      _lastRun = DateTime.MinValue;
    }
    public Scheduler (
      ISynchronizerFactory synchronizerFactory,
      ISynchronizationReportSink reportSink,
      Action ensureSynchronizationContext, 
      IFolderChangeWatcherFactory folderChangeWatcherFactory,
      ISynchronizationRunLogger runLogger)
    {
      if (synchronizerFactory == null)
        throw new ArgumentNullException (nameof (synchronizerFactory));
      if (ensureSynchronizationContext == null)
        throw new ArgumentNullException (nameof (ensureSynchronizationContext));
      if (folderChangeWatcherFactory == null)
        throw new ArgumentNullException (nameof (folderChangeWatcherFactory));
      if (runLogger == null)
        throw new ArgumentNullException (nameof (runLogger));
      if (reportSink == null)
        throw new ArgumentNullException (nameof (reportSink));

      _reportSink = reportSink;
      _synchronizerFactory = synchronizerFactory;
      _ensureSynchronizationContext = ensureSynchronizationContext;
      _folderChangeWatcherFactory = folderChangeWatcherFactory;
      _runLogger = runLogger;
      _synchronizationTimer.Tick += SynchronizationTimer_Tick;
      _synchronizationTimer.Interval = (int) _timerInterval.TotalMilliseconds;
    }
        public SynchronizationProfileRunner(
            ISynchronizerFactory synchronizerFactory,
            ISynchronizationReportSink reportSink,
            IFolderChangeWatcherFactory folderChangeWatcherFactory,
            Action ensureSynchronizationContext,
            ISynchronizationRunLogger runLogger,
            IDateTimeProvider dateTimeProvider,
            Guid profileId)
        {
            if (synchronizerFactory == null)
            {
                throw new ArgumentNullException(nameof(synchronizerFactory));
            }
            if (reportSink == null)
            {
                throw new ArgumentNullException(nameof(reportSink));
            }
            if (folderChangeWatcherFactory == null)
            {
                throw new ArgumentNullException(nameof(folderChangeWatcherFactory));
            }
            if (ensureSynchronizationContext == null)
            {
                throw new ArgumentNullException(nameof(ensureSynchronizationContext));
            }
            if (runLogger == null)
            {
                throw new ArgumentNullException(nameof(runLogger));
            }
            if (dateTimeProvider == null)
            {
                throw new ArgumentNullException(nameof(dateTimeProvider));
            }

            _profileId                    = profileId;
            _synchronizerFactory          = synchronizerFactory;
            _reportSink                   = reportSink;
            _folderChangeWatcherFactory   = folderChangeWatcherFactory;
            _ensureSynchronizationContext = ensureSynchronizationContext;
            _runLogger                    = runLogger;
            _dateTimeProvider             = dateTimeProvider;
            // Set to min, to ensure that it runs on the first run after startup
            _lastRun = DateTime.MinValue;
            _errorHandlingStrategy = new ErrorHandlingStrategy(_profile, _dateTimeProvider, 0);
        }
        public Scheduler(
            ISynchronizerFactory synchronizerFactory,
            ISynchronizationReportSink reportSink,
            Action ensureSynchronizationContext,
            IFolderChangeWatcherFactory folderChangeWatcherFactory,
            ISynchronizationRunLogger runLogger)
        {
            if (synchronizerFactory == null)
            {
                throw new ArgumentNullException(nameof(synchronizerFactory));
            }
            if (ensureSynchronizationContext == null)
            {
                throw new ArgumentNullException(nameof(ensureSynchronizationContext));
            }
            if (folderChangeWatcherFactory == null)
            {
                throw new ArgumentNullException(nameof(folderChangeWatcherFactory));
            }
            if (runLogger == null)
            {
                throw new ArgumentNullException(nameof(runLogger));
            }
            if (reportSink == null)
            {
                throw new ArgumentNullException(nameof(reportSink));
            }

            _reportSink                   = reportSink;
            _synchronizerFactory          = synchronizerFactory;
            _ensureSynchronizationContext = ensureSynchronizationContext;
            _folderChangeWatcherFactory   = folderChangeWatcherFactory;
            _runLogger = runLogger;
            _synchronizationTimer.Tick    += SynchronizationTimer_Tick;
            _synchronizationTimer.Interval = (int)_timerInterval.TotalMilliseconds;
            _synchronizationTimer.Start();
        }
        public SynchronizationProfileRunner(
            ISynchronizerFactory synchronizerFactory,
            ISynchronizationReportSink reportSink,
            IFolderChangeWatcherFactory folderChangeWatcherFactory,
            Action ensureSynchronizationContext,
            ISynchronizationRunLogger runLogger)
        {
            if (synchronizerFactory == null)
            {
                throw new ArgumentNullException(nameof(synchronizerFactory));
            }
            if (reportSink == null)
            {
                throw new ArgumentNullException(nameof(reportSink));
            }
            if (folderChangeWatcherFactory == null)
            {
                throw new ArgumentNullException(nameof(folderChangeWatcherFactory));
            }
            if (ensureSynchronizationContext == null)
            {
                throw new ArgumentNullException(nameof(ensureSynchronizationContext));
            }
            if (runLogger == null)
            {
                throw new ArgumentNullException(nameof(runLogger));
            }

            _synchronizerFactory          = synchronizerFactory;
            _reportSink                   = reportSink;
            _folderChangeWatcherFactory   = folderChangeWatcherFactory;
            _ensureSynchronizationContext = ensureSynchronizationContext;
            _runLogger = runLogger;
            // Set to min, to ensure that it runs on the first run after startup
            _lastRun = DateTime.MinValue;
        }