/// <summary>
        /// Create a new directory scanning monitor
        /// </summary>
        /// <param name="monitorFileName">The file name to save the list of monitored directories
        /// to</param>
        /// <param name="scanInterval">The <see cref="ScanInterval"/> in seconds</param>
        /// <param name="baseDirectory">The base directory to use for the archives of this
        /// monitor</param>
        /// <param name="defaultArchive">The default archive to use</param>
        /// <param name="otherArchives">Other archives for specific extensions</param>
        public DirectoryScanningMonitor(string monitorFileName, double scanInterval, string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
            : base(baseDirectory, defaultArchive, otherArchives) {
            MonitoredDirectoriesFilePath = Path.Combine(baseDirectory, monitorFileName);
            folders = new List<string>();

            ScanTimer = new ReentrantTimer(() => UpdateArchives());
            ScanTimer.AutoReset = true;
            ScanInterval = scanInterval;
        }
        /// <summary>
        /// Creates a new AbstractFileMonitor with the default archive and a collection of
        /// non-default archives that should be registered
        /// </summary>
        /// <param name="baseDirectory">The folder where this monitor stores it archives</param>
        /// <param name="defaultArchive">The default archive</param>
        /// <param name="otherArchives">A list of other archives that should be registered via see
        /// cref="RegisterArchive(IArchive)"/></param>
        protected AbstractFileMonitor(string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives) {
            this.MonitorStoragePath = baseDirectory;
            this.registeredArchives = new HashSet<AbstractArchive>();
            this.archiveMap = new Dictionary<string, AbstractArchive>(StringComparer.OrdinalIgnoreCase);
            this.ReadyState = new ReadyNotifier(this);
            this.numberOfWorkingArchives = 0;
            Factory = Task.Factory;

            if(null != defaultArchive) {
                RegisterArchive(defaultArchive, true);
            }
            
            foreach(var archive in otherArchives) {
                this.RegisterArchive(archive, false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new AbstractFileMonitor with the default archive and a collection of
        /// non-default archives that should be registered
        /// </summary>
        /// <param name="baseDirectory">The folder where this monitor stores it archives</param>
        /// <param name="defaultArchive">The default archive</param>
        /// <param name="otherArchives">A list of other archives that should be registered via see
        /// cref="RegisterArchive(IArchive)"/></param>
        protected AbstractFileMonitor(TaskScheduler scheduler, string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
        {
            this.MonitorStoragePath      = baseDirectory;
            this.registeredArchives      = new HashSet <AbstractArchive>();
            this.archiveMap              = new Dictionary <string, AbstractArchive>(StringComparer.OrdinalIgnoreCase);
            this.ReadyState              = new ReadyNotifier(this);
            this.numberOfWorkingArchives = 0;
            Factory = new TaskFactory(scheduler);

            if (null != defaultArchive)
            {
                RegisterArchive(defaultArchive, true);
            }

            foreach (var archive in otherArchives)
            {
                this.RegisterArchive(archive, false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Registers an archive in the file monitor. All file changes will be automatically routed
 /// to the appropriate archive based on file extension (via
 /// <see cref="AbstractArchive.SupportedExtensions"/>
 /// </summary>
 /// <param name="archive">the archive to add.</param>
 /// <param name="isDefault">whether or not to use this archive as the default
 /// archive</param>
 public void RegisterArchive(AbstractArchive archive, bool isDefault)
 {
     this.registeredArchives.Add(archive);
     archive.FileChanged += RespondToArchiveFileEvent;
     if (isDefault)
     {
         this.defaultArchive = archive;
     }
     else
     {
         foreach (var extension in archive.SupportedExtensions)
         {
             if (archiveMap.ContainsKey(extension))
             {
                 SrcMLFileLogger.DefaultLogger.WarnFormat("AbstractFileMonitor.RegisterNonDefaultArchive() - Archive already registered for extension {0}, will be replaced with the new archive.", extension);
             }
             archiveMap[extension] = archive;
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Create a new archive monitor
 /// </summary>
 /// <param name="scheduler">The scheduler to use</param>
 /// <param name="baseDirectory">The base directory for this monitor</param>
 /// <param name="monitoredArchive">The archive to monitor (found in <see cref="MonitoredArchive"/>)</param>
 /// <param name="defaultArchive">The default archive to store data in</param>
 /// <param name="otherArchives">Other archives to store data in</param>
 public ArchiveMonitor(TaskScheduler scheduler, string baseDirectory, TArchive monitoredArchive, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : base(scheduler, baseDirectory, defaultArchive, otherArchives)
 {
     MonitoredArchive = monitoredArchive;
 }
Esempio n. 6
0
 /// <summary>
 /// Create a new archive monitor
 /// </summary>
 /// <param name="baseDirectory">The base directory for this monitor</param>
 /// <param name="monitoredArchive">The archive to monitor (found in <see cref="MonitoredArchive"/>)</param>
 /// <param name="defaultArchive">The default archive to store data in</param>
 /// <param name="otherArchives">Other archives to store data in</param>
 public ArchiveMonitor(string baseDirectory, TArchive monitoredArchive, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : this(TaskScheduler.Default, baseDirectory, monitoredArchive, defaultArchive, otherArchives)
 {
 }
 /// <summary>
 /// Creates a new file system monitor
 /// </summary>
 /// <param name="pathToSourceFolder">The folder to watch</param>
 /// <param name="monitoringStorage">The base directory for the archive data</param>
 /// <param name="defaultArchive">The default archive</param>
 /// <param name="otherArchives">Other archives to register</param>
 public FileSystemFolderMonitor(string pathToSourceFolder, string monitoringStorage, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : base(monitoringStorage, defaultArchive, otherArchives)
 {
     this.FullFolderPath      = pathToSourceFolder;
     this._monitorStorageInfo = new DirectoryInfo(monitoringStorage);
     SetupFileSystemWatcher();
 }
 /// <summary>
 /// Creates a new file system monitor
 /// </summary>
 /// <param name="pathToSourceFolder">The folder to watch</param>
 /// <param name="monitoringStorage">The base directory for the archive data</param>
 /// <param name="defaultArchive">The default archive</param>
 /// <param name="otherArchives">Other archives to register</param>
 public FileSystemFolderMonitor(string pathToSourceFolder, string monitoringStorage, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : base(monitoringStorage, defaultArchive, otherArchives) {
     this.FullFolderPath = pathToSourceFolder;
     this._monitorStorageInfo = new DirectoryInfo(monitoringStorage);
     SetupFileSystemWatcher();
 }
 /// <summary>
 /// Create a new directory scanning monitor
 /// </summary>
 /// <param name="foldersToMonitor">An initial list of
 /// <see cref="MonitoredDirectories">folders to </see> monitor</param>
 /// <param name="baseDirectory">The base directory to use for the archives of this
 /// monitor</param>
 /// <param name="defaultArchive">The default archive to use</param>
 /// <param name="otherArchives">Other archives for specific extensions</param>
 public DirectoryScanningMonitor(string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : this(MONITOR_LIST_FILENAME, DEFAULT_SCAN_INTERVAL, baseDirectory, defaultArchive, otherArchives) { }
 /// <summary>
 /// Create a new directory scanning monitor
 /// </summary>
 /// <param name="foldersToMonitor">An initial list of
 /// <see cref="MonitoredDirectories">folders to /see></param>
 /// <param name="scanInterval">The <see cref="ScanInterval"/> in seconds</param>
 /// <param name="baseDirectory">The base directory to use for the archives of this
 /// monitor</param>
 /// <param name="defaultArchive">The default archive to use</param>
 /// <param name="otherArchives">Other archives for specific extensions</param>
 public DirectoryScanningMonitor(double scanInterval, string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : this(MONITOR_LIST_FILENAME, scanInterval, baseDirectory, defaultArchive, otherArchives) { }
Esempio n. 11
0
 /// <summary>
 /// Registers an archive in the file monitor. All file changes will be automatically routed
 /// to the appropriate archive based on file extension (via
 /// <see cref="AbstractArchive.SupportedExtensions"/>
 /// </summary>
 /// <param name="archive">the archive to add.</param>
 /// <param name="isDefault">whether or not to use this archive as the default
 /// archive</param>
 public void RegisterArchive(AbstractArchive archive, bool isDefault) {
     this.registeredArchives.Add(archive);
     archive.FileChanged += RespondToArchiveFileEvent;
     if(isDefault) {
         this.defaultArchive = archive;
     } else {
         foreach(var extension in archive.SupportedExtensions) {
             if(archiveMap.ContainsKey(extension)) {
                 SrcMLFileLogger.DefaultLogger.WarnFormat("AbstractFileMonitor.RegisterNonDefaultArchive() - Archive already registered for extension {0}, will be replaced with the new archive.", extension);
             }
             archiveMap[extension] = archive;
         }
     }
 }
        /// <summary>
        /// Create a new directory scanning monitor
        /// </summary>
        /// <param name="monitorFileName">The file name to save the list of monitored directories
        /// to</param>
        /// <param name="scanInterval">The <see cref="ScanInterval"/> in seconds</param>
        /// <param name="baseDirectory">The base directory to use for the archives of this
        /// monitor</param>
        /// <param name="defaultArchive">The default archive to use</param>
        /// <param name="otherArchives">Other archives for specific extensions</param>
        public DirectoryScanningMonitor(string monitorFileName, double scanInterval, TaskScheduler scheduler, string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
            : base(scheduler, baseDirectory, defaultArchive, otherArchives)
        {
            MonitoredDirectoriesFilePath = Path.Combine(baseDirectory, monitorFileName);
            folders = new List <string>();

            ScanTimer           = new ReentrantTimer(() => UpdateArchivesAsync(), scheduler);
            ScanTimer.AutoReset = true;
            ScanInterval        = scanInterval;
        }
 /// <summary>
 /// Create a new directory scanning monitor
 /// </summary>
 /// <param name="foldersToMonitor">An initial list of
 /// <see cref="MonitoredDirectories">folders to </see> monitor</param>
 /// <param name="baseDirectory">The base directory to use for the archives of this
 /// monitor</param>
 /// <param name="defaultArchive">The default archive to use</param>
 /// <param name="otherArchives">Other archives for specific extensions</param>
 public DirectoryScanningMonitor(string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : this(MONITOR_LIST_FILENAME, DEFAULT_SCAN_INTERVAL, baseDirectory, defaultArchive, otherArchives)
 {
 }
 /// <summary>
 /// Create a new directory scanning monitor
 /// </summary>
 /// <param name="foldersToMonitor">An initial list of
 /// <see cref="MonitoredDirectories">folders to /see></param>
 /// <param name="scanInterval">The <see cref="ScanInterval"/> in seconds</param>
 /// <param name="baseDirectory">The base directory to use for the archives of this
 /// monitor</param>
 /// <param name="defaultArchive">The default archive to use</param>
 /// <param name="otherArchives">Other archives for specific extensions</param>
 public DirectoryScanningMonitor(double scanInterval, string baseDirectory, AbstractArchive defaultArchive, params AbstractArchive[] otherArchives)
     : this(MONITOR_LIST_FILENAME, scanInterval, baseDirectory, defaultArchive, otherArchives)
 {
 }