コード例 #1
0
        public IAwaitableTransfer LoadFile(Uri remoteUri)
        {
            var progress = new OngoingReactiveProgress1();
            var transfer = _downloader.Load(remoteUri, progress, CancellationToken.None);
            //TODO: FileCache.TryGetFileModel
            var fileModel = await _fileCache.CachedFiles.FirstOrDefaultAsync();

            if (fileModel != null || cacheInfo.Downloaded < cacheInfo.FinalSize)
            {
                //if (not downloaded OR download not finished)
                var progress = new OngoingReactiveProgress1();
                target.SetRealReactiveProgress(progress);
                //TODO: progress.Subscribe( { save CacheInfo as progress goes} );
                var transfer = await _downloader.Load(_item.PodcastUri, progress, CancellationToken.None);
                //TODO: think how to implement via Move (should atomically call Move and Save info into cache)
                CachedUri = await _storage.MoveFromTransferTempStorage(transfer.DownloadLocation, _item);
                var newCacheInfo = new CacheInfo()
                {
                    FileUri = CachedUri,
                    FinalSize = progress.FinalState.Total,
                    Downloaded = progress.FinalState.Total
                };
                await Cache.Local.InsertObject(_item.OriginalUri.OriginalString, newCacheInfo);
            }
            else
            {
                CachedUri = cacheInfo.FileUri;
                var progress = new FinishedReactiveProgress<ProgressValue>(new ProgressValue(cacheInfo.Downloaded, cacheInfo.FinalSize));
                target.SetRealReactiveProgress(progress);
            }
        }
コード例 #2
0
        public void CachingState_VM_Progressing_Test_With_Deferred_Progress()
        {
            var progress = new DeferredReactiveProgress(default(ProgressValue));
            var vm = new CachingStateVm(progress);
            
            var reporter = new OngoingReactiveProgress1();
            reporter.Report(new ProgressValue(1,10));
            progress.SetRealReactiveProgress(reporter);

            Assert.Equal(1ul, vm.CachedSize);
            Assert.Equal(10ul, vm.FinalSize);
            Assert.False(vm.IsFullyCached);
        }