Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring.IO.MsBuildFileSystemWatcherEntries.RenameDirectory C# (CSharp) Méthode

RenameDirectory() public méthode

public RenameDirectory ( string previousRelativePath, string relativePath, string shortPath ) : ISet
previousRelativePath string
relativePath string
shortPath string
Résultat ISet
        public ISet<string> RenameDirectory(string previousRelativePath, string relativePath, string shortPath) {
            try {
                previousRelativePath = PathHelper.EnsureTrailingSlash(previousRelativePath);
                relativePath = PathHelper.EnsureTrailingSlash(relativePath);
                shortPath = PathHelper.EnsureTrailingSlash(shortPath);
                var newPaths = new HashSet<string>();
                var entriesToRename = _entries.Values
                    .Where(v => v.State == Unchanged || v.State == Added || v.State == RenamedThenAdded)
                    .Where(v => EntryPathStartsWith(v, previousRelativePath)).ToList();
                foreach (var entry in entriesToRename) {
                    var newEntryPath = entry.RelativePath.Replace(previousRelativePath, relativePath, 0, previousRelativePath.Length);
                    RenameEntry(entry.RelativePath, newEntryPath, shortPath, entry.Type);
                    newPaths.Add(newEntryPath);
                }
                return newPaths;
            } catch (InvalidStateException) {
                RescanRequired = true;
                return null;
            }
        }

Usage Example

            public void Apply()
            {
                if (!_fullPath.StartsWithIgnoreCase(_rootDirectory))
                {
                    DeleteInsteadOfRename();
                    return;
                }

                var newDirectoryInfo = _fileSystem.GetDirectoryInfo(_fullPath);
                var newRelativePath  = PathHelper.EnsureTrailingSlash(PathHelper.MakeRelative(_rootDirectory, _fullPath));

                if (!newDirectoryInfo.Exists || !_fileSystemFilter.IsDirectoryAllowed(newRelativePath, newDirectoryInfo.Attributes))
                {
                    DeleteInsteadOfRename();
                    return;
                }

                var oldRelativePath = PathHelper.MakeRelative(_rootDirectory, _oldFullPath);

                if (_entries.ContainsDirectoryEntry(oldRelativePath))
                {
                    _entries.RenameDirectory(oldRelativePath, newRelativePath, _fileSystem.ToShortRelativePath(_fullPath, _rootDirectory));
                }
                else
                {
                    (new DirectoryCreated(_entries, _rootDirectory, _fileSystem, _fileSystemFilter, _fullPath)).Apply();
                }
            }