Beispiel #1
0
        protected override async Task RefreshInternal(CancellationToken token)
        {
            var info = await Task.Run(() => new DriveInfo(FullName), token);

            await Dispatcher.Invoke(() => Set(info));

            var isEmpty = await _factory.IsEmpty(this);

            if (isEmpty)
            {
                await Clear(token);

                return;
            }

            var children = await _factory.GetChildren(this, _fileAttributes, _folderAttributes);

            if (!IsLoaded)
            {
                await AddRange(children);
            }
            else
            {
                await Dispatcher.Invoke(() => Items.UpdateItems(children, FileSystemViewModelFactoryExtensions.IFileSystemChildComparer, FileSystemViewModelFactoryExtensions.IFileSystemChildMapper));
            }
        }
        public static async Task <IReadOnlyCollection <IFileSystemChild> > GetChildren(this IFileSystemViewModelFactory factory, IFileSystemDirectory parent, IReadOnlyCollection <FileAttributes> fileAttributes, IReadOnlyCollection <FileAttributes> folderAttributes)
        {
            var canAccess = await factory.CanAccess(parent);

            if (!canAccess)
            {
                return(Enumerable.Empty <IFileSystemChild>().ToList());
            }

            return(await factory.GetChildren((IFileSystemParent)parent, fileAttributes, folderAttributes));
        }