public async Task Rename(IFileExplorerEntry fileExplorerEntry, string newName) { await Task.Run(() => _fileExplorerCommand.RenameEntry(fileExplorerEntry, newName)); var newPath = Path.Combine(Path.GetDirectoryName(fileExplorerEntry.Path), newName); var oldPath = fileExplorerEntry.Path; FileExplorerEntryRenamed?.Invoke(this, new EntryRenamedInfo(fileExplorerEntry, newName, newPath)); fileExplorerEntry.Name = newName; foreach (var cachedEntry in _cachedEntries.Where(x => x.Key.StartsWith(oldPath, StringComparison.OrdinalIgnoreCase)).ToList()) { _cachedEntries.TryRemove(cachedEntry.Key, out var foo); var newKey = newPath + cachedEntry.Key.Substring(oldPath.Length); cachedEntry.Value.DirectoryEntry.Path = newKey; lock (cachedEntry.Value) foreach (var explorerEntry in cachedEntry.Value.Entries) { explorerEntry.Path = newPath + explorerEntry.Path.Substring(oldPath.Length); } if (_cachedEntries.ContainsKey(newKey)) { _cachedEntries[newKey] = cachedEntry.Value; } else { _cachedEntries.TryAdd(newKey, cachedEntry.Value); } } fileExplorerEntry.Path = newPath; }
/// <inheritdoc /> public bool Equals(IFileExplorerEntry other) { var directoryEntry = other as DirectoryEntry; if (directoryEntry == null) { return(false); } return(string.Equals(other.Path, Path, StringComparison.OrdinalIgnoreCase)); }
/// <inheritdoc /> public bool Equals(IFileExplorerEntry other) { var fileEntry = other as ProcessingEntry; if (fileEntry == null) { return(false); } return(string.Equals(other.Path, Path, StringComparison.OrdinalIgnoreCase)); }
/// <inheritdoc /> public bool Equals(IFileExplorerEntry other) { var fileEntry = other as FileEntry; if (fileEntry == null) { return(false); } return(Path == null || other.Path == null ? string.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase) : string.Equals(other.Path, Path, StringComparison.OrdinalIgnoreCase)); }
public async Task <EntryDeletionFailed> Remove(IFileExplorerEntry fileExplorerEntry) { return((await Remove(new[] { fileExplorerEntry })).FirstOrDefault()); }
public EntryDeletionFailed(string errorMessage, IFileExplorerEntry entry) { ErrorMessage = errorMessage; Entry = entry; }
public EntryRenamedInfo(IFileExplorerEntry fileExplorerEntry, string newName, string newPath) { FileExplorerEntry = fileExplorerEntry; NewName = newName; NewPath = newPath; }
public EntryAddedInfo(IFileExplorerEntry addedEntry, string path) { AddedEntry = addedEntry; Path = path; }
public void RenameEntry(IFileExplorerEntry fileExplorerEntry, string newName) { LogService.Send(string.Format((string)Application.Current.Resources["RenameEntry"], fileExplorerEntry.Name, newName)); _dtpFactory.ExecuteProcedure("RenameEntry", fileExplorerEntry.ToEntryInfo(), newName); }