public void Move(ICloudDrive drive, string newName, CloudDirectoryNode destinationDirectory) { if (drive == null) { throw new ArgumentNullException(nameof(drive)); } if (string.IsNullOrEmpty(newName)) { throw new ArgumentNullException(nameof(newName)); } if (destinationDirectory == null) { throw new ArgumentNullException(nameof(destinationDirectory)); } if (Parent == null) { throw new InvalidOperationException($"{nameof(Parent)} of {GetType().Name} '{Name}' is null".ToString(CultureInfo.CurrentCulture)); } var moveItem = CreateNew(drive.MoveItem(Contract, newName, destinationDirectory.Contract)); if (destinationDirectory.children != null) { destinationDirectory.children.Add(moveItem.Name, moveItem); moveItem.SetParent(destinationDirectory); } else { destinationDirectory.GetChildItems(drive); } Parent.children.Remove(Name); SetParent(null); }
public CloudDirectoryNode NewDirectoryItem(ICloudDrive drive, string fileName) { var newItem = new CloudDirectoryNode(drive.NewDirectoryItem(Contract, fileName)); children.Add(newItem.Name, newItem); newItem.SetParent(this); return newItem; }
public void Move(ICloudDrive drive, string newName, CloudDirectoryNode destinationDirectory) { var moveItem = CreateNew(drive.MoveItem(Contract, newName, destinationDirectory.Contract)); if (destinationDirectory.children != null) { destinationDirectory.children.Add(moveItem.Name, moveItem); moveItem.SetParent(destinationDirectory); } else { destinationDirectory.GetChildItems(drive); } parent.children.Remove(Name); SetParent(null); }
private CloudItemNode GetItem(string fileName) { var result = root ?? (root = new CloudDirectoryNode(drive.GetRoot())) as CloudItemNode; var pathSegments = new Queue <string>(fileName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries)); while (result != null && pathSegments.Count > 0) { result = (result as CloudDirectoryNode)?.GetChildItemByName(drive, pathSegments.Dequeue()); } return(result); }
public CloudDirectoryNode NewDirectoryItem(ICloudDrive drive, string directoryName) { if (drive == null) { throw new ArgumentNullException(nameof(drive)); } var newItem = new CloudDirectoryNode(drive.NewDirectoryItem(Contract, directoryName)); children.Add(newItem.Name, newItem); newItem.SetParent(this); return(newItem); }
public virtual void SetParent(CloudDirectoryNode parent) { Parent = parent; }
public override void SetParent(CloudDirectoryNode parent) { base.SetParent(parent); Contract.Directory = parent?.Contract; }
public override void SetParent(CloudDirectoryNode parent) { base.SetParent(parent); Contract.Parent = parent?.Contract; }
private CloudItemNode GetItem(string fileName) { var result = root ?? (root = new CloudDirectoryNode(drive.GetRoot())) as CloudItemNode; var pathSegments = new Queue<string>(fileName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries)); while (result != null && pathSegments.Count > 0) result = (result as CloudDirectoryNode)?.GetChildItemByName(drive, pathSegments.Dequeue()); return result; }
public virtual void SetParent(CloudDirectoryNode parent) { this.parent = parent; }