/// <summary> /// Sets up the monitor prior to <see cref="AbstractMonitoringService.StartMonitoring"/> /// </summary> protected override void Setup() { var openSolution = GetOpenSolution(); if (null != openSolution) { var storagePath = GetBaseDirectory(openSolution); if (ShouldReset()) { Directory.Delete(storagePath, true); } CurrentMonitor = new SourceMonitor(openSolution, DirectoryScanningMonitor.DEFAULT_SCAN_INTERVAL, GlobalScheduler, storagePath); CurrentProject = new SrcMLProject(GlobalScheduler, CurrentMonitor, new SrcMLGenerator(Path.Combine(ServiceProvider.ExtensionDirectory, "SrcML"))); CurrentMonitor.DirectoryAdded += CurrentMonitor_DirectoryAdded; CurrentMonitor.DirectoryRemoved += CurrentMonitor_DirectoryRemoved; CurrentMonitor.UpdateArchivesStarted += CurrentMonitor_UpdateArchivesStarted; CurrentMonitor.UpdateArchivesCompleted += CurrentMonitor_UpdateArchivesCompleted; CurrentMonitor.FileChanged += CurrentMonitor_FileChanged; CurrentMonitor.AddDirectoriesFromSaveFile(); if (0 == CurrentMonitor.MonitoredDirectories.Count) { CurrentMonitor.AddSolutionDirectories(); } } }
/// <summary> /// SrcML service starts to monitor the opened solution. /// </summary> /// <param name="srcMLArchiveDirectory"></param> /// <param name="shouldReset"></param> public void StartMonitoring(bool shouldReset, string srcMLBinaryDirectory) { // Get the path of the folder that storing the srcML archives var openSolution = GetOpenSolution(); string baseDirectory = GetSrcMLArchiveFolder(openSolution); SrcMLFileLogger.DefaultLogger.Info("SrcMLGlobalService.StartMonitoring( " + baseDirectory + " )"); try { if (shouldReset) { SrcMLFileLogger.DefaultLogger.Info("Reset flag is set - Removing " + baseDirectory); Directory.Delete(baseDirectory, true); } CurrentMonitor = new SourceMonitor(openSolution, DirectoryScanningMonitor.DEFAULT_SCAN_INTERVAL, _taskManager.GlobalScheduler, baseDirectory); CurrentProject = new SrcMLProject(_taskManager.GlobalScheduler, CurrentMonitor, new SrcMLGenerator(srcMLBinaryDirectory)); // Create a new instance of SrcML.NET's solution monitor if (openSolution != null) { CurrentMonitor.DirectoryAdded += RespondToDirectoryAddedEvent; CurrentMonitor.DirectoryRemoved += RespondToDirectoryRemovedEvent; CurrentMonitor.UpdateArchivesStarted += CurrentMonitor_UpdateArchivesStarted; CurrentMonitor.UpdateArchivesCompleted += CurrentMonitor_UpdateArchivesCompleted; CurrentMonitor.AddDirectoriesFromSaveFile(); if (0 == CurrentMonitor.MonitoredDirectories.Count) { CurrentMonitor.AddSolutionDirectories(); } } // Subscribe events from Solution Monitor if (CurrentMonitor != null) { CurrentMonitor.FileChanged += RespondToFileChangedEvent; // Initialize the progress bar. if (statusBar != null) { statusBar.Progress(ref cookie, 1, "", 0, 0); } // Start monitoring var updateTask = CurrentMonitor.UpdateArchivesAsync(); CurrentMonitor.StartMonitoring(); OnMonitoringStarted(new EventArgs()); SaveTimer.Start(); } } catch (Exception e) { SrcMLFileLogger.DefaultLogger.Error(SrcMLExceptionFormatter.CreateMessage(e, "Exception in SrcMLGlobalService.StartMonitoring()")); } }
/// <summary> /// SrcML service starts to monitor the opened solution. /// </summary> /// <param name="srcMLArchiveDirectory"></param> /// <param name="shouldReset"></param> public void StartMonitoring(bool shouldReset, string srcMLBinaryDirectory) { // Get the path of the folder that storing the srcML archives var openSolution = GetOpenSolution(); string baseDirectory = GetSrcMLArchiveFolder(openSolution); SrcMLFileLogger.DefaultLogger.Info("SrcMLGlobalService.StartMonitoring( " + baseDirectory + " )"); try { if(shouldReset) { SrcMLFileLogger.DefaultLogger.Info("Reset flag is set - Removing " + baseDirectory); Directory.Delete(baseDirectory, true); } CurrentMonitor = new SourceMonitor(openSolution, DirectoryScanningMonitor.DEFAULT_SCAN_INTERVAL, _taskManager.GlobalScheduler, baseDirectory); CurrentProject = new SrcMLProject(_taskManager.GlobalScheduler, CurrentMonitor, new SrcMLGenerator(srcMLBinaryDirectory)); // Create a new instance of SrcML.NET's solution monitor if(openSolution != null) { CurrentMonitor.DirectoryAdded += RespondToDirectoryAddedEvent; CurrentMonitor.DirectoryRemoved += RespondToDirectoryRemovedEvent; CurrentMonitor.UpdateArchivesStarted += CurrentMonitor_UpdateArchivesStarted; CurrentMonitor.UpdateArchivesCompleted += CurrentMonitor_UpdateArchivesCompleted; CurrentMonitor.AddDirectoriesFromSaveFile(); if(0 == CurrentMonitor.MonitoredDirectories.Count) { CurrentMonitor.AddSolutionDirectories(); } } // Subscribe events from Solution Monitor if(CurrentMonitor != null) { CurrentMonitor.FileChanged += RespondToFileChangedEvent; // Initialize the progress bar. if(statusBar != null) { statusBar.Progress(ref cookie, 1, "", 0, 0); } // Start monitoring var updateTask = CurrentMonitor.UpdateArchivesAsync(); CurrentMonitor.StartMonitoring(); OnMonitoringStarted(new EventArgs()); SaveTimer.Start(); } } catch(Exception e) { SrcMLFileLogger.DefaultLogger.Error(SrcMLExceptionFormatter.CreateMessage(e, "Exception in SrcMLGlobalService.StartMonitoring()")); } }
/// <summary> /// Sets up the monitor prior to <see cref="AbstractMonitoringService.StartMonitoring"/> /// </summary> protected override void Setup() { var openSolution = GetOpenSolution(); if(null != openSolution) { var storagePath = GetBaseDirectory(openSolution); if(ShouldReset()) { Directory.Delete(storagePath, true); } CurrentMonitor = new SourceMonitor(openSolution, DirectoryScanningMonitor.DEFAULT_SCAN_INTERVAL, GlobalScheduler, storagePath); CurrentProject = new SrcMLProject(GlobalScheduler, CurrentMonitor, new SrcMLGenerator(Path.Combine(ServiceProvider.ExtensionDirectory, "SrcML"))); CurrentMonitor.DirectoryAdded += CurrentMonitor_DirectoryAdded; CurrentMonitor.DirectoryRemoved += CurrentMonitor_DirectoryRemoved; CurrentMonitor.UpdateArchivesStarted += CurrentMonitor_UpdateArchivesStarted; CurrentMonitor.UpdateArchivesCompleted += CurrentMonitor_UpdateArchivesCompleted; CurrentMonitor.FileChanged += CurrentMonitor_FileChanged; CurrentMonitor.AddDirectoriesFromSaveFile(); if(0 == CurrentMonitor.MonitoredDirectories.Count) { CurrentMonitor.AddSolutionDirectories(); } } }