/// <summary> /// Wires all of the properties together /// </summary> protected void SetupMonitor(SrcMLGenerator generator) { // setup the file monitor NonSourceArchive = new LastModifiedArchive(StoragePath, LastModifiedArchive.DEFAULT_FILENAME, Scheduler); var archiveDirectory = Path.Combine(StoragePath, SrcMLArchive.DEFAULT_ARCHIVE_DIRECTORY); SourceArchive = new SrcMLArchive(StoragePath, SrcMLArchive.DEFAULT_ARCHIVE_DIRECTORY, true, generator, new SrcMLFileNameMapping(archiveDirectory), Scheduler); Monitor.RegisterArchive(NonSourceArchive, true); Monitor.RegisterArchive(SourceArchive, false); }
/// <summary> /// SrcML service starts to monitor the opened solution. /// </summary> /// <param name="srcMLArchiveDirectory"></param> /// <param name="useExistingSrcML"></param> public void StartMonitoring(bool useExistingSrcML, string srcMLBinaryDirectory) { // Get the path of the folder that storing the srcML archives string srcMLArchiveDirectory = GetSrcMLArchiveFolder(SolutionMonitorFactory.GetOpenSolution()); SrcMLFileLogger.DefaultLogger.Info("SrcMLGlobalService.StartMonitoring( " + srcMLArchiveDirectory + " )"); try { // Create a new instance of SrcML.NET's LastModifiedArchive LastModifiedArchive lastModifiedArchive = new LastModifiedArchive(srcMLArchiveDirectory); // Create a new instance of SrcML.NET's SrcMLArchive SrcMLArchive sourceArchive = new SrcMLArchive(srcMLArchiveDirectory, useExistingSrcML, new SrcMLGenerator(srcMLBinaryDirectory)); CurrentSrcMLArchive = sourceArchive; // Create a new instance of SrcML.NET's solution monitor CurrentMonitor = SolutionMonitorFactory.CreateMonitor(srcMLArchiveDirectory, lastModifiedArchive, sourceArchive); // Subscribe events from Solution Monitor CurrentMonitor.FileChanged += RespondToFileChangedEvent; CurrentMonitor.IsReadyChanged += RespondToIsReadyChangedEvent; CurrentMonitor.MonitoringStopped += RespondToMonitoringStoppedEvent; // Initialize the progress bar. if(statusBar != null) { statusBar.Progress(ref cookie, 1, "", 0, 0); } // Start monitoring duringStartup = true; CurrentMonitor.StartMonitoring(); } catch(Exception e) { SrcMLFileLogger.DefaultLogger.Error(SrcMLExceptionFormatter.CreateMessage(e, "Exception in SrcMLGlobalService.StartMonitoring()")); } }