Esempio n. 1
0
File: core.cs Progetto: ovg1985/sync
        public void Run()
        {
            ILogger logger = new CompoundLogger()
            {
                Logs = new ILogger[] {
                    new EventLogger(),
                    new ConsoleLogger()
                    {
                        Verbosity = Verbosity
                    }
                }
            };

            ChangesMonitor monitor = new ChangesMonitor(logger)
            {
                SourcePath = SourcePath,
                Excludes   = Excludes
            };

            ChangesTransmitter transmitter = new ChangesTransmitter(logger)
            {
                Host            = Host,
                User            = User,
                PrivateKey      = PrivateKey,
                Passphrase      = Passphrase,
                DestinationPath = DestinationPath,
                DryRun          = DryRun,
                Excludes        = Excludes,
            };

            monitor.TurnOn();
            transmitter.WaitChanges(monitor, () => false);
        }
Esempio n. 2
0
File: core.cs Progetto: ovg1985/sync
        public void Start(Predicate cancelPoller)
        {
            OnChangesWait();
            ILogger logger = new EventLogger();

            /// add delegates
            ChangesMonitor monitor = new ChangesMonitor(logger)
            {
                SourcePath = SourcePath,
                Excludes   = Excludes,
            };

            ChangesTransmitter transmitter = new ChangesTransmitter(logger)
            {
                Host            = Host,
                User            = User,
                PrivateKey      = PrivateKey,
                Passphrase      = Passphrase,
                DestinationPath = DestinationPath,
                Excludes        = Excludes,
            };

            monitor.OnChangesCollect += OnChangesProcessed;
            monitor.OnWait           += OnChangesWait;

            monitor.TurnOn();

            var cancelListen = new Task(new Action(() => {
                while (!cancelPoller())
                {
                    Thread.Sleep(1000);
                }

                //monitor.TurnOff();
                transmitter.Stop();
            }));

            cancelListen.Start();

            transmitter.WaitChanges(monitor, cancelPoller);
            OnStop();
            logger.Info("Stopping...");
        }