Exemple #1
0
        private bool tryGetWatcher(VirtualDirectory src, out VirtualDirectoryWatcher watcher)
        {
            lock (_lockObject)
            {
                watcher = null;
                if (_isDisposed)
                {
                    return(false);
                }

                var retv = _directoryWatchers.ContainsKey(src);
                if (retv)
                {
                    watcher = _directoryWatchers[src];
                }

                return(retv);
            }
        }
Exemple #2
0
        public VirtualDirectoryWatcher Alloc(VirtualDirectory directory)
        {
            lock (_lockObject)
            {
                if (_isDisposed)
                {
                    throw new ObjectDisposedException(nameof(VirtualDirectoryWatcherSource));
                }

                if (!_directoryWatchers.ContainsKey(directory))
                {
                    var newWatcher = new VirtualDirectoryWatcher(directory, this);
                    _directoryWatchers[directory]    = newWatcher;
                    _watchersAllocations[newWatcher] = 0;
                }

                var watcher = _directoryWatchers[directory];
                _watchersAllocations[watcher]++;
                return(watcher);
            }
        }
Exemple #3
0
 internal VirtualDirectoryWatcher(VirtualDirectory directory, VirtualDirectoryWatcherSource source)
 {
     Directory = directory ?? throw new ArgumentNullException(nameof(directory));
     _source   = source ?? throw new ArgumentNullException(nameof(source));
 }
Exemple #4
0
 internal void RaiseDeleted(VirtualDirectory directory)
 {
     DirectoryEvent?.Invoke(this, new DirectoryEventArgs(directory, WatcherEvent.Deleted));
 }
Exemple #5
0
 internal DirectoryEventArgs(VirtualDirectory directory, WatcherEvent @event)
 {
     Directory = directory;
     Event     = @event;
 }