void OnDeleted(object sender, FileSystemEventArgs e)
        {
            var path = GetVirtualPath(e.FullPath);

            if (path.IsDirectory)
            {
                directoryNameSet.Remove(path.EntityName);
            }

            RaiseChanged(FileSystemChange.FromDeleted(path));
        }
        void OnCreated(object sender, FileSystemEventArgs e)
        {
            if (System.IO.Directory.Exists(e.FullPath))
            {
                directoryNameSet.Add(Path.GetFileName(e.FullPath));
            }

            var path = GetVirtualPath(e.FullPath);

            RaiseChanged(FileSystemChange.FromCreated(path));
        }
        void OnRenamed(object sender, RenamedEventArgs e)
        {
            var oldPath = GetVirtualPath(e.OldFullPath);
            var newPath = GetVirtualPath(e.FullPath);

            if (oldPath.IsDirectory)
            {
                directoryNameSet.Remove(oldPath.EntityName);
            }
            if (newPath.IsDirectory)
            {
                directoryNameSet.Add(newPath.EntityName);
            }

            RaiseChanged(FileSystemChange.FromRenamed(oldPath, newPath));
        }
예제 #4
0
        void OnChanged(object sender, FileSystemChange e)
        {
            switch (e.ChangeType)
            {
            case WatcherChangeTypes.Created:
                if (e.NewPath.ParentPath == path)
                {
                    RaiseChanged(e);
                }
                break;

            case WatcherChangeTypes.Changed:
                if (e.NewPath.ParentPath == path)
                {
                    RaiseChanged(e);
                }
                break;

            case WatcherChangeTypes.Deleted:
                if (e.OldPath.ParentPath == path)
                {
                    RaiseChanged(e);
                }
                break;

            case WatcherChangeTypes.Renamed:
                if (e.OldPath.ParentPath == path)
                {
                    if (e.NewPath.ParentPath == path)
                    {
                        RaiseChanged(e);
                    }
                    else
                    {
                        RaiseChanged(FileSystemChange.FromDeleted(e.OldPath));
                    }
                }
                else
                {
                    if (e.NewPath.ParentPath == path)
                    {
                        RaiseChanged(FileSystemChange.FromCreated(e.NewPath));
                    }
                }
                break;
            }
        }
예제 #5
0
 void RaiseChanged(FileSystemChange change)
 {
     Changed?.Invoke(this, change);
 }
        void OnChanged(object sender, FileSystemEventArgs e)
        {
            var path = GetVirtualPath(e.FullPath);

            RaiseChanged(FileSystemChange.FromChanged(path));
        }