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)
        {
            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 CloudPathResolver(ICloudDrive drive)
        {
            if (drive == null)
                throw new ArgumentNullException(nameof(drive));

            this.drive = drive;
        }
        public IEnumerable <CloudItemNode> GetChildItems(ICloudDrive drive)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            if (children == null)
            {
                lock (Contract)
                {
                    if (children == null)
                    {
                        children = drive
                                   .GetChildItem(Contract)
                                   .Select(f => CreateNew(f)).ToDictionary(i => i.Name);

                        foreach (var child in children.Values)
                        {
                            child.SetParent(this);
                        }
                    }
                }
            }

            return(children.Values);
        }
 public CloudFileNode NewFileItem(ICloudDrive drive, string fileName)
 {
     var newItem = new CloudFileNode(drive.NewFileItem(Contract, fileName, new MemoryStream()));
     children.Add(newItem.Name, newItem);
     newItem.SetParent(this);
     return newItem;
 }
        public CloudItemNode GetChildItemByName(ICloudDrive drive, string fileName)
        {
            GetChildItems(drive);

            var result = default(CloudItemNode);
            children.TryGetValue(fileName, out result);
            return result;
        }
Exemple #7
0
        public Stream GetContent(ICloudDrive drive)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            return(drive.GetContent(Contract));
        }
Exemple #8
0
        public void Truncate(ICloudDrive drive)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            drive.SetContent(Contract, Stream.Null);
        }
        public CloudPathResolver(ICloudDrive drive)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            this.drive = drive;
        }
        public CloudItemNode GetChildItemByName(ICloudDrive drive, string fileName)
        {
            GetChildItems(drive);

            var result = default(CloudItemNode);

            children.TryGetValue(fileName, out result);
            return(result);
        }
Exemple #11
0
        public CloudOperations(ICloudDrive drive, ILogger logger)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            this.drive  = drive;
            this.logger = logger;
        }
        public void Remove(ICloudDrive drive)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            Parent.children.Remove(Name);
            drive.RemoveItem(Contract, false);
            SetParent(null);
        }
 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);
 }
        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 CloudFileNode NewFileItem(ICloudDrive drive, string fileName)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            var newItem = new CloudFileNode(drive.NewFileItem(Contract, fileName, Stream.Null));

            children.Add(newItem.Name, newItem);
            newItem.SetParent(this);
            return(newItem);
        }
        public NtStatus Unmounted(DokanFileInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            var result = AsTrace(nameof(Unmounted), null, info, DokanResult.Success);

            _drive  = null;
            _logger = null;

            return(result);
        }
        public IEnumerable<CloudItemNode> GetChildItems(ICloudDrive drive)
        {
            if (children == null) {
                lock (Contract) {
                    if (children == null) {
                        children = drive.GetChildItem(Contract).Select(f => CloudItemNode.CreateNew(f)).ToDictionary(i => i.Name);

                        foreach (var child in children.Values)
                            child.SetParent(this);
                    }
                }
            }

            return children.Values;
        }
Exemple #18
0
        public void SetContent(ICloudDrive drive, Stream stream)
        {
            if (drive == null)
            {
                throw new ArgumentNullException(nameof(drive));
            }

            var proxyFileInfoContract = Contract as ProxyFileInfoContract;

            if (proxyFileInfoContract != null)
            {
                ResolveContract(drive.NewFileItem(Parent.Contract, proxyFileInfoContract.Name, stream));
            }
            else
            {
                drive.SetContent(Contract, stream);
            }
        }
 public void Remove(ICloudDrive drive)
 {
     parent.children.Remove(Name);
     drive.RemoveItem(Contract, false);
     SetParent(null);
 }
        public NtStatus Unmounted(DokanFileInfo info)
        {
            var result = Trace(nameof(Unmounted), null, info, DokanResult.Success);

            drive = null;
            logger = null;

            return result;
        }
 public CloudOperations(ICloudDrive drive, ILogger logger)
 {
     this.drive = drive;
     this.logger = logger;
 }
 public Stream GetContent(ICloudDrive drive)
 {
     return drive.GetContent(Contract);
 }
 public void SetContent(ICloudDrive drive, Stream stream)
 {
     drive.SetContent(Contract, stream);
 }
 public void Truncate(ICloudDrive drive)
 {
     drive.SetContent(Contract, new MemoryStream());
 }
 public CloudOperations(ICloudDrive drive, ILogger logger)
 {
     _drive  = drive ?? throw new ArgumentNullException(nameof(drive));
     _logger = logger;
 }
 public BackgroundSync(TimeSpan interval, TimeSpan timeout, ICloudDrive g) : base("Background Synchronization", interval, timeout)
 {
     this.g = (GoogleDriveDownloader)g;
 }