Esempio n. 1
0
        protected virtual void Dispose(bool disposing)
        {
            Logging.Debug("FolderWatcher::Dispose({0}) @{1}", disposing, dispose_count);

            try
            {
                if (dispose_count == 0)
                {
                    // Get rid of managed resources
                    file_system_watcher.EnableRaisingEvents = false;
                    file_system_watcher.Dispose();
                }

                file_system_watcher = null;

                folder_watcher_manager = null;
                //library.Dispose();
                library = null;
                tags.Clear();
                configured_folder_to_watch = null;
                aspiring_folder_to_watch   = null;
            }
            catch (Exception ex)
            {
                Logging.Error(ex);
            }

            ++dispose_count;
        }
        public FolderWatcher(FolderWatcherManager folder_watcher_manager, Library library, string folder_to_watch, string tags)
        {
            this.folder_watcher_manager = folder_watcher_manager;
            this.library                  = library;
            this.folder_to_watch          = folder_to_watch;
            this.tags                     = TagTools.ConvertTagBundleToTags(tags);
            this.previous_folder_to_watch = null;

            file_system_watcher = new FileSystemWatcher();
            file_system_watcher.IncludeSubdirectories = true;
            file_system_watcher.Filter   = "*.pdf";
            file_system_watcher.Changed += file_system_watcher_Changed;
            file_system_watcher.Created += file_system_watcher_Created;
            previous_folder_to_watch     = null;
            folder_contents_has_changed  = false;

            file_system_watcher.Path = null;
            file_system_watcher.EnableRaisingEvents = false;
        }
        public FolderWatcher(FolderWatcherManager _folder_watcher_manager, WebLibraryDetail _library, string folder_to_watch, string _tags)
        {
            folder_watcher_manager   = new TypedWeakReference <FolderWatcherManager>(_folder_watcher_manager);
            web_library_detail       = new TypedWeakReference <WebLibraryDetail>(_library);
            aspiring_folder_to_watch = folder_to_watch;
            tags = TagTools.ConvertTagBundleToTags(_tags);
            configured_folder_to_watch = null;

            watch_stats = new WatchStatistics();

            file_system_watcher = new FileSystemWatcher();
            file_system_watcher.IncludeSubdirectories = true;
            file_system_watcher.Filter   = "*.pdf";
            file_system_watcher.Changed += file_system_watcher_Changed;
            file_system_watcher.Created += file_system_watcher_Created;
            configured_folder_to_watch   = null;
            FolderContentsHaveChanged    = false;

            file_system_watcher.Path = null;
            file_system_watcher.EnableRaisingEvents = false;
        }