protected PollingFileSystemWatcher(SerializationInfo info, StreamingContext context)
        {
            _state    = (PathToFileStateHashtable)info.GetValue(nameof(_state), typeof(PathToFileStateHashtable));
            _version  = info.GetInt64(nameof(_version));
            _started  = info.GetBoolean(nameof(_started));
            _disposed = info.GetBoolean(nameof(_disposed));

            Path               = info.GetString(nameof(Path));
            Filter             = info.GetString(nameof(Filter));
            EnumerationOptions = new EnumerationOptions {
                RecurseSubdirectories = info.GetBoolean(nameof(EnumerationOptions.RecurseSubdirectories))
            };

            _timer          = new Timer(new TimerCallback(TimerHandler));
            PollingInterval = info.GetInt32(nameof(PollingInterval));
        }
        private void Resize()
        {
            // this is because sometimes we just need to garbade collect instead of increase size
            int newSize = Math.Max(Count * 2, 4);

            PathToFileStateHashtable bigger = new PathToFileStateHashtable(newSize);

            foreach (FileState existingValue in this)
            {
                bigger.Add(existingValue.Directory, existingValue.Path, existingValue);
            }
            Values  = bigger.Values;
            Buckets = bigger.Buckets;
            this._nextValuesIndex = bigger._nextValuesIndex;
            this.Count            = bigger.Count;
        }
        /// <summary>
        /// Creates an instance of a watcher
        /// </summary>
        /// <param name="path">The path to watch.</param>
        /// <param name="filter">The type of files to watch. For example, "*.txt" watches for changes to all text files.</param>
        public PollingFileSystemWatcher(string path, string filter = "*", EnumerationOptions options = null)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (!Directory.Exists(path))
            {
                throw new ArgumentException("Path not found.", nameof(path));
            }

            _state             = new PathToFileStateHashtable();
            Path               = path;
            Filter             = filter ?? throw new ArgumentNullException(nameof(filter));
            EnumerationOptions = options ?? new EnumerationOptions();
            _timer             = new Timer(new TimerCallback(TimerHandler));
        }
 public Enumerator(PathToFileStateHashtable table)
 {
     _table = table;
     _index = 0;
 }