Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public bool Equals(IFileExplorerEntry other)
        {
            var directoryEntry = other as DirectoryEntry;

            if (directoryEntry == null)
            {
                return(false);
            }

            return(string.Equals(other.Path, Path, StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public bool Equals(IFileExplorerEntry other)
        {
            var fileEntry = other as ProcessingEntry;

            if (fileEntry == null)
            {
                return(false);
            }

            return(string.Equals(other.Path, Path, StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 4
0
        /// <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));
        }
Exemplo n.º 5
0
 public async Task <EntryDeletionFailed> Remove(IFileExplorerEntry fileExplorerEntry)
 {
     return((await Remove(new[] { fileExplorerEntry })).FirstOrDefault());
 }
Exemplo n.º 6
0
 public EntryDeletionFailed(string errorMessage, IFileExplorerEntry entry)
 {
     ErrorMessage = errorMessage;
     Entry        = entry;
 }
Exemplo n.º 7
0
 public EntryRenamedInfo(IFileExplorerEntry fileExplorerEntry, string newName, string newPath)
 {
     FileExplorerEntry = fileExplorerEntry;
     NewName           = newName;
     NewPath           = newPath;
 }
Exemplo n.º 8
0
 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);
 }