public async Task <IPackageSearchMetadata> GetPackageMetadataAsync(PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) { var tasks = _sourceRepositories .Select(r => r.GetPackageMetadataAsync(identity, includePrerelease, cancellationToken)) .ToList(); if (_localRepository != null) { tasks.Add(_localRepository.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken)); } var ignored = tasks .Select(task => task.ContinueWith(LogError, TaskContinuationOptions.OnlyOnFaulted)) .ToArray(); var completed = (await Task.WhenAll(tasks)) .Where(m => m != null); var master = completed.FirstOrDefault(m => !string.IsNullOrEmpty(m.Summary)) ?? completed.FirstOrDefault() ?? PackageSearchMetadataBuilder.FromIdentity(identity).Build(); return(master.WithVersions( asyncValueFactory: () => MergeVersionsAsync(identity, completed))); }
private async Task <IPackageSearchMetadata> GetPackageMetadataAsync(PackageIdentity identity, List <Task <IPackageSearchMetadata> > tasks, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (_localRepository != null) { tasks.Add(_localRepository.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken)); } IEnumerable <IPackageSearchMetadata> completed = (await Task.WhenAll(tasks)) .Where(m => m != null); IPackageSearchMetadata master = completed.FirstOrDefault(m => !string.IsNullOrEmpty(m.Summary)) ?? completed.FirstOrDefault() ?? PackageSearchMetadataBuilder.FromIdentity(identity).Build(); return(master.WithVersions( asyncValueFactory: () => MergeVersionsAsync(identity, completed))); }
public async Task <IPackageSearchMetadata> GetLocalPackageMetadataAsync(PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) { var result = await _localRepository.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken); if (result == null) { result = await _globalLocalRepository?.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken); if (result == null) { return(null); } } return(result.WithVersions(asyncValueFactory: () => FetchAndMergeVersionsAsync(identity, includePrerelease, cancellationToken))); }