Esempio n. 1
0
        /// <summary>
        /// handles an item being deleted.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Item_Deleted(object sender, DirectoryItemDeletedEventArgs e)
        {
            // unregister the item.
            var currentMode = _visitMode;

            _visitMode = VisitMode.Unregister;
            e.DeletedItem.Accept(this);
            _visitMode = currentMode;
            OnRaiseItemDeleted(e);
        }
Esempio n. 2
0
        protected virtual void OnRaiseItemDeleted(DirectoryItemDeletedEventArgs args)
        {
            // Only raise the event if the item/s matches watch pattern.
            var matches = GetMatchingFilters(args.DeletedItem.Path).ToArray();

            if (matches.Length > 0)
            {
                var watcherArgs = new DirectoryWatcherFilterMatchedEventArgs <DirectoryItemDeletedEventArgs>(args, matches);
                EventHandler <DirectoryWatcherFilterMatchedEventArgs <DirectoryItemDeletedEventArgs> > handler = ItemDeleted;
                handler?.Invoke(this, watcherArgs);
            }
            ;
        }
Esempio n. 3
0
        protected virtual void OnRaiseItemDeleted()
        {
            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            EventHandler <DirectoryItemDeletedEventArgs> handler = Deleted;

            // Event will be null if there are no subscribers
            if (handler != null)
            {
                var args = new DirectoryItemDeletedEventArgs(this);

                // Use the () operator to raise the event.
                handler(this, args);
            }
        }