Exemplo n.º 1
0
        private void InitializeWorkspace(IPythonWorkspaceContext workspace)
        {
            lock (_factories) {
                // Cleanup state associated with the previous workspace, if any
                if (_workspace != null)
                {
                    _workspace.InterpreterSettingChanged -= OnInterpreterSettingChanged;
                    _workspace = null;
                }

                _folderWatcher?.Dispose();
                _folderWatcher = null;
                _folderWatcherTimer?.Dispose();
                _folderWatcherTimer = null;

                // Setup new workspace
                _workspace = workspace;
                if (_workspace != null)
                {
                    _workspace.InterpreterSettingChanged += OnInterpreterSettingChanged;
                    try {
                        _folderWatcher                       = new FileWatcher(_workspace.Location, "*.*");
                        _folderWatcher.Created              += OnFileCreatedDeletedRenamed;
                        _folderWatcher.Deleted              += OnFileCreatedDeletedRenamed;
                        _folderWatcher.Renamed              += OnFileCreatedDeletedRenamed;
                        _folderWatcher.EnableRaisingEvents   = true;
                        _folderWatcher.IncludeSubdirectories = true;
                    } catch (ArgumentException) {
                    } catch (IOException) {
                    }
                    _folderWatcherTimer = new Timer(OnFileChangesTimerElapsed);
                }
            }
        }
 private void CleanupFileWatcher()
 {
     if (FileWatcher != null)
     {
         FileWatcher.Dispose();
         FileWatcher = null;
     }
 }
Exemplo n.º 3
0
 public void RemoveWatcher()
 {
     if (projectWatcher != null)
     {
         projectWatcher.Stop();
         projectWatcher.Dispose();
         projectWatcher = null;
     }
 }
Exemplo n.º 4
0
        private void Clenaup()
        {
            _logEvents?.OnCompleted();
            _reset?.OnCompleted();

            _logEvents?.Dispose();
            _reset?.Dispose();
            _fileWatcher?.Dispose();
        }
Exemplo n.º 5
0
        public void Stop()
        {
            IsRunning = false;

            if (_watcher != null)
            {
                _watcher.Dispose();
                _watcher = null;
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public override void Destroy()
        {
            GameBase.Game.Window.FileDropped           -= OnFileDropped;
            AppDomain.CurrentDomain.UnhandledException -= OnCrash;

            if (MapManager.Selected.Value.Game == MapGame.Quaver)
            {
                FileWatcher.Dispose();
            }

            BeatSnap.Dispose();
            Metronome.Dispose();
            base.Destroy();
        }
Exemplo n.º 7
0
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         _workspaceContextProvider.WorkspaceOpening -= OnWorkspaceOpening;
         _workspaceContextProvider.WorkspaceClosed  -= OnWorkspaceClosed;
         if (_workspace != null)
         {
             _workspace.InterpreterSettingChanged -= OnInterpreterSettingChanged;
         }
         if (_folderWatcher != null)
         {
             _folderWatcher.Dispose();
         }
         if (_folderWatcherTimer != null)
         {
             _folderWatcherTimer.Dispose();
         }
     }
 }
Exemplo n.º 8
0
        private void btnFile_Click(object sender, RoutedEventArgs e)
        {
            var folderDialog = new FolderSelectDialog();

            folderDialog.InitialDirectory = _fileWatcher?.InputFolder ?? Environment.CurrentDirectory;

            // Show open file dialog box
            var result = folderDialog.ShowDialog();

            // Process open file dialog box results
            if (result)
            {
                // Open document
                var folderName = folderDialog.FolderName;
                lbFolder.Text = folderName;

                btnStart.Content      = "Start";
                _isFileWatcherRunning = false;

                //Dispose all outstanding tasks (if any)
                _fileWatcher?.Dispose();
                _fileWatcher = new FileWatcher(folderName);


                //Dispose all subscription if it exists.
                _subscription?.Dispose();
                //Register action happens when new message signaled.
                _subscription = _fileWatcher.InputValue.ObserveOnDispatcher().Subscribe((msg) =>
                {
                    _session?.Messages.Add(new Message()
                    {
                        Content   = msg,
                        Timestamp = DateTime.Now
                    });
                });

                //Create new session for output to UI
                _session    = new Session(folderName);
                DataContext = _session;
            }
        }
Exemplo n.º 9
0
        private void MiOpenFile_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog fileBrowserDialog = new Microsoft.Win32.OpenFileDialog();
            fileBrowserDialog.RestoreDirectory = true;
            fileBrowserDialog.Multiselect      = false;
            if (fileBrowserDialog.ShowDialog() == true)
            {
                fw?.Dispose();

                fw = new FileWatcher(fileBrowserDialog.FileName);
                Lb_EcondingChanged(this, fw.Encoding);
                fw.EcondingChanged += Lb_EcondingChanged;

                sl = new ScrollLogic(fw, textBox.Dispatcher);
                STextBox.ScrollLogic     = sl;
                sl.FollowTail            = followTail;
                eofMarker.Fill           = new SolidColorBrush(Color.FromRgb(127, 127, 127));
                sl.IsAtEndOfFileChanged += (_, isAtEnd) => {
                    eofMarker.Fill = new SolidColorBrush(isAtEnd ? Color.FromRgb(0, 0, 255) : Color.FromRgb(127, 127, 127));
                };
                sl.Init(0, Origin.Begin, STextBox.LinesOnScreen);
            }
        }
Exemplo n.º 10
0
        public void ShouldWatchDeletedFile()
        {
            // Arrange
            FileWatcherEventArgs args        = null;
            const string         fileName    = "FileWatcherDelete.test";
            FileWatcher          fileWatcher = new FileWatcher(new FileInfo(fileName));

            fileWatcher.OnChange += (s, a) => args = a;
            using (StreamWriter writer = File.CreateText(fileName))
            {
                writer.WriteLine();
                writer.Flush();
            }

            // Act
            fileWatcher.Start();
            File.Delete(fileName);
            Thread.Sleep(1200);
            fileWatcher.Dispose();

            // Assert
            Assert.IsNotNull(args);
            Assert.IsTrue(args.IsFileDeleted);
        }
Exemplo n.º 11
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    CancelSource.Cancel();
                    try
                    {
                        DedupTask?.Wait();
                    }
                    catch (AggregateException exc)
                    {
                        exc.Handle(x => x is OperationCanceledException);
                    }
                    CancelSource?.Dispose();
                    DedupTask?.Dispose();
                    FileWatcher?.Dispose();
                    // TODO: dispose managed state (managed objects)
                }

                disposedValue = true;
            }
        }
        private bool disposedValue = false; // To detect redundant calls

        /// <summary>
        /// Dispose of this instance
        /// </summary>
        /// <param name="disposing">
        /// True if this is called from the Dispose method.
        /// False if this is called from the finalizer.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (_dataUpdateService != null)
                    {
                        _dataUpdateService.UnRegisterDataFile(this);
                        _dataUpdateService = null;
                    }
                    if (FileWatcher != null)
                    {
                        FileWatcher.Dispose();
                    }
                    if (Timer != null)
                    {
                        Timer.Dispose();
                    }
                }

                disposedValue = true;
            }
        }
Exemplo n.º 13
0
        public void Dispose()
        {
            var watcher = new FileWatcher(".");

            watcher.Dispose();
        }
Exemplo n.º 14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void close() throws java.io.IOException
        public override void Close()
        {
            @delegate.Dispose();
        }