Esempio n. 1
0
        private void Process(object item)
        {
            _EventWaitHandle.WaitOne();

            FileSystemEventArgs e = item as FileSystemEventArgs;

            switch (e.ChangeType)
            {
            case WatcherChangeTypes.Changed:

                if (!FilterFileExtensions.Contains(PathHelper.GetFilenameExtension(e.Name)))
                {
                    return;
                }

                OnItemChanged(e.Name);
                break;

            case WatcherChangeTypes.Created:

                if (Directory.Exists(e.FullPath))
                {
                    BinaryInsertDirectoryCache(e.Name);
                    return;
                }

                if (!FilterFileExtensions.Contains(PathHelper.GetFilenameExtension(e.Name)))
                {
                    return;
                }

                if (File.Exists(e.FullPath))
                {
                    BinaryInsertFileCache(e.Name);
                }

                break;

            case WatcherChangeTypes.Deleted:

                if (DirectoryCache.Remove(e.Name))
                {
                    OnDirectoryRemoved(e.Name);
                    return;
                }

                if (!FilterFileExtensions.Contains(PathHelper.GetFilenameExtension(e.Name)))
                {
                    return;
                }

                if (FileCache.Remove(e.Name))
                {
                    OnFileRemoved(e.Name);
                }

                break;

            case WatcherChangeTypes.Renamed:
                Process_ItemRenamed(item as RenamedEventArgs);
                break;
            }
        }