public FileSystemInfoLocator(FileSystemInfoContract fileSystem) { if (fileSystem == null) throw new ArgumentNullException(nameof(fileSystem)); Id = fileSystem.Id; Name = fileSystem.Name; ParentId = (fileSystem as DirectoryInfoContract)?.Parent.Id ?? (fileSystem as FileInfoContract)?.Directory.Id; }
public FileSystemInfoLocator(FileSystemInfoContract fileSystem) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } Id = fileSystem.Id; Name = fileSystem.Name; ParentId = (fileSystem as DirectoryInfoContract)?.Parent.Id ?? (fileSystem as FileInfoContract)?.Directory.Id; }
public CloudPathNode(FileSystemInfoContract fileSystemInfo) { var directoryInfo = fileSystemInfo as DirectoryInfoContract; if (directoryInfo != null) { itemMode = Mode.Directory; nodeValue = new ContainerPathValue(directoryInfo, directoryInfo.Name); return; } var fileInfo = fileSystemInfo as FileInfoContract; if (fileInfo != null) { itemMode = Mode.File; nodeValue = new LeafPathValue(fileInfo, fileInfo.Name); return; } throw new InvalidOperationException(); }
public FileSystemInfoContract RenameItem(FileSystemInfoContract target, string newName) { return gateway.RenameItem(rootName, target.Id, newName); }
public void RemoveItem(FileSystemInfoContract target, bool recurse) { gateway.RemoveItem(rootName, target.Id, recurse); InvalidateDrive(); }
public FileSystemInfoContract MoveItem(FileSystemInfoContract source, string movePath, DirectoryInfoContract destination) { InvalidateDrive(); return gateway.MoveItem(rootName, source.Id, movePath, destination.Id); }
public FileSystemInfoContract CopyItem(FileSystemInfoContract source, string copyPath, DirectoryInfoContract destination, bool recurse) { InvalidateDrive(); return gateway.CopyItem(rootName, source.Id, copyPath, destination.Id, recurse); }
public FileSystemInfoContract RenameItem(FileSystemInfoContract target, string newName) { try { Func<FileSystemInfoLocator> locator = () => new FileSystemInfoLocator(target); return gateway.RenameItemAsync(rootName, target.Id, newName, locator).Result; } catch (AggregateException ex) when (ex.InnerExceptions.Count == 1) { throw ex.InnerExceptions[0]; } }
public void RemoveItem(FileSystemInfoContract target, bool recurse) { try { gateway.RemoveItemAsync(rootName, target.Id, recurse).Wait(); } catch (AggregateException ex) when (ex.InnerExceptions.Count == 1) { throw ex.InnerExceptions[0]; } finally { InvalidateDrive(); } }
public FileSystemInfoContract MoveItem(FileSystemInfoContract source, string movePath, DirectoryInfoContract destination) { try { Func<FileSystemInfoLocator> locator = () => new FileSystemInfoLocator(source); return gateway.MoveItemAsync(rootName, source.Id, movePath, destination.Id, locator).Result; } catch (AggregateException ex) when (ex.InnerExceptions.Count == 1) { throw ex.InnerExceptions[0]; } finally { InvalidateDrive(); } }
public FileSystemInfoContract CopyItem(FileSystemInfoContract source, string copyPath, DirectoryInfoContract destination, bool recurse) { try { return gateway.CopyItemAsync(rootName, source.Id, copyPath, destination.Id, recurse).Result; } catch (AggregateException ex) when (ex.InnerExceptions.Count == 1) { throw ex.InnerExceptions[0]; } finally { InvalidateDrive(); } }