コード例 #1
0
        byte _version; // this is used to keep track of removals. // TODO: describe the algorithm

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates an instance of a watcher
        /// </summary>
        /// <param name="rootDirectory">The directory to watch. It does not support UNC paths (yet).</param>
        /// <param name="pollingIntervalInMilliseconds">Polling interval</param>
        public PollingWatcher(string rootDirectory, bool includeSubdirectories = false, int pollingIntervalInMilliseconds = 1000)
        {
            Tracing = new TraceSource("PollingWatcher");
            _state = new PathToFileStateHashtable(Tracing);
            _pollingIntervalInMilliseconds = pollingIntervalInMilliseconds;
            _includeSubdirectories = includeSubdirectories;
            _directories.Add(ToDirectoryFormat(rootDirectory));
        }
コード例 #2
0
        byte _version;                   // this is used to keep track of removals. // TODO: describe the algorithm

        /// <summary>
        /// Creates an instance of a watcher
        /// </summary>
        /// <param name="rootDirectory">The directory to watch. It does not support UNC paths (yet).</param>
        /// <param name="includeSubdirectories">A bool controlling whether or not subdirectories will be watched too</param>
        /// <param name="pollingIntervalInMilliseconds">Polling interval</param>
        public PollingWatcher(string rootDirectory, bool includeSubdirectories = false, int pollingIntervalInMilliseconds = 1000)
        {
            Tracing = new TraceSource("PollingWatcher");
            _state  = new PathToFileStateHashtable(Tracing);
            _pollingIntervalInMilliseconds = pollingIntervalInMilliseconds;
            _includeSubdirectories         = includeSubdirectories;
            _directories.Add(ToDirectoryFormat(rootDirectory));
        }
コード例 #3
0
        /// <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 (!Directory.Exists(path))
            {
                throw new ArgumentException("Path not found.", nameof(path));
            }

            _state             = new PathToFileStateHashtable();
            Path               = path;
            Filter             = filter;
            EnumerationOptions = null ?? new EnumerationOptions();
            _timer             = new Timer(new TimerCallback(TimerHandler));
        }
コード例 #4
0
        private void Resize()
        {
            // this is because sometimes we just need to garbade collect instead of increase size
            var newSize = Math.Max(_count * 2, 4);

            var bigger = new PathToFileStateHashtable(newSize);

            foreach (var existingValue in this)
            {
                bigger.Add(existingValue.Directory, existingValue.Path, existingValue);
            }
            Values  = bigger.Values;
            Buckets = bigger.Buckets;
            this._nextValuesIndex = bigger._nextValuesIndex;
            this._count           = bigger._count;
        }
コード例 #5
0
        private void Resize()
        {
            // this is because sometimes we just need to garbade collect instead of increase size
            var newSize = Math.Max(_count * 2, 4);

            if (_trace.Switch.ShouldTrace(TraceEventType.Verbose))
            {
                _trace.TraceEvent(TraceEventType.Verbose, 5, "Resizing hashtable from {0} to {1}", Values.Length, newSize);
            }

            var bigger = new PathToFileStateHashtable(_trace, newSize);

            foreach (var existingValue in this)
            {
                bigger.Add(existingValue.Directory, existingValue.Path, existingValue);
            }
            Values  = bigger.Values;
            Buckets = bigger.Buckets;
            this._nextValuesIndex = bigger._nextValuesIndex;
            this._count           = bigger._count;
        }
コード例 #6
0
 public Enumerator(PathToFileStateHashtable table)
 {
     _table = table;
     _index = 0;
 }
コード例 #7
0
 public Enumerator(PathToFileStateHashtable table)
 {
     _table = table;
     _index = 0;
 }
コード例 #8
0
        private void Resize()
        {
            // this is because sometimes we just need to garbade collect instead of increase size
            var newSize = Math.Max(_count * 2, 4);

            if (_trace.Switch.ShouldTrace(TraceEventType.Verbose))
            {
                _trace.TraceEvent(TraceEventType.Verbose, 5, "Resizing hashtable from {0} to {1}", Values.Length, newSize);
            }

            var bigger = new PathToFileStateHashtable(_trace, newSize);

            foreach (var existingValue in this)
            {
                bigger.Add(existingValue.Directory, existingValue.Path, existingValue);
            }
            Values = bigger.Values;
            Buckets = bigger.Buckets;
            this._nextValuesIndex = bigger._nextValuesIndex;
            this._count = bigger._count;
        }