Exemple #1
0
        static void Main(string[] args)
        {
            var autoreloadPath = "_autoreload";
            var lastUpdate     = DateTime.Now;

            using (var dirCopy = new LiveDirCopy(new DirectoryInfo("."), autoreloadPath))
                using (var runner = new OwinRunner(autoreloadPath))
                    using (var watcher = new DirWatcher(".", autoreloadPath))
                    {
                        runner.Start();

                        Observable
                        .FromEventPattern(watcher, "OnChanged")
                        .Select(PathFromEventArgs)
                        .Buffer(EveryHalfSecond())
                        .Where(SomethingHasHappened)
                        .Select(paths => paths.Distinct())
                        .Subscribe(paths =>
                        {
                            runner.Stop();
                            foreach (var path in paths)
                            {
                                dirCopy.Update(path);
                            }
                            runner.Start();
                        });

                        Console.WriteLine("...");
                        Console.ReadLine();
                    }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var autoreloadPath = "_autoreload";
            var lastUpdate = DateTime.Now;
            using (var dirCopy = new LiveDirCopy(new DirectoryInfo("."), autoreloadPath))
            using (var runner = new OwinRunner(autoreloadPath))
            using (var watcher = new DirWatcher(".", autoreloadPath))
            {
                runner.Start();

                Observable
                    .FromEventPattern(watcher, "OnChanged")
                    .Select(PathFromEventArgs)
                    .Buffer(EveryHalfSecond())
                    .Where(SomethingHasHappened)
                    .Select(paths => paths.Distinct())
                    .Subscribe(paths =>
                        {
                            runner.Stop();
                            foreach (var path in paths)
                            {
                                dirCopy.Update(path);
                            }
                            runner.Start();
                        });

                Console.WriteLine("...");
                Console.ReadLine();
            }
        }