コード例 #1
0
        protected override Task <IReadOnlyCollection <IGoogleDriveFile> > PopulateFolderAsync(ITreeNodeContainer folderNode, CancellationToken ct, IProgress <string> progress)
        {
            if (!folderNode.ChildrenTask.IsCompleted)
            {
                var parent = folderNode.CastTo <TreeNodeContainer>().DataItem.CastTo <IGoogleDriveFolder>();
                if (parent.IsMyDriveFile() || (parent.File.IsNot <GoogleTeamDrive>() && parent.IsTeamDriveFile()))
                {
                    Items.Clear();

                    var observable = _gService.GetChildFilesObservable(parent, ct: ct);
                    observable.Buffer(TimeSpan.FromMilliseconds(400))
                    .ObserveOn(SynchronizationContext.Current)
                    .Subscribe(lf => Items.AddRange(lf.SelectMany(i => i)), RaiseFilesPopulated);

                    return(Task.FromResult(Empty));
                }
            }

            return(base.PopulateFolderAsync(folderNode, ct, progress));
        }