private static async Task <IList <string> > GetListEndpointsAsync(IPackageSourceProvider sourceProvider) { var configurationSources = sourceProvider.LoadPackageSources() .Where(p => p.IsEnabled) .ToList(); var sourceRepositoryProvider = new CommandLineSourceRepositoryProvider(sourceProvider); var listCommandResourceTasks = configurationSources.Select(source => sourceRepositoryProvider.CreateRepository(source)).Select(sourceRepository => sourceRepository.GetResourceAsync <ListCommandResource>()).ToList(); var listCommandResources = await Task.WhenAll(listCommandResourceTasks).ConfigureAwait(false); var listEndpoints = new List <string>(); foreach (var listCommandResource in listCommandResources) { string listEndpoint = null; if (listCommandResource != null) { listEndpoint = listCommandResource.GetListEndpoint(); } if (listEndpoint != null) { listEndpoints.Add(listEndpoint); } } return(listEndpoints); }
private async Task <IList <string> > GetListEndpointsAsync() { var configurationSources = SourceProvider.LoadPackageSources() .Where(p => p.IsEnabled) .ToList(); IList <Configuration.PackageSource> packageSources; if (Source.Count > 0) { packageSources = Source .Select(s => Common.PackageSourceProviderExtensions.ResolveSource(configurationSources, s)) .ToList(); } else { packageSources = configurationSources; } var sourceRepositoryProvider = new CommandLineSourceRepositoryProvider(SourceProvider); var listCommandResourceTasks = new List <Task <ListCommandResource> >(); foreach (var source in packageSources) { var sourceRepository = sourceRepositoryProvider.CreateRepository(source); listCommandResourceTasks.Add(sourceRepository.GetResourceAsync <ListCommandResource>()); } var listCommandResources = await Task.WhenAll(listCommandResourceTasks); var listEndpoints = new List <string>(); for (int i = 0; i < listCommandResources.Length; i++) { string listEndpoint = null; var listCommandResource = listCommandResources[i]; if (listCommandResource != null) { listEndpoint = listCommandResource.GetListEndpoint(); } if (listEndpoint != null) { listEndpoints.Add(listEndpoint); } else { var message = string.Format( LocalizedResourceManager.GetString("ListCommand_ListNotSupported"), packageSources[i].Source); Console.LogWarning(message); } } return(listEndpoints); }
private async Task <IList <KeyValuePair <Configuration.PackageSource, string> > > GetListEndpointsAsync() { var configurationSources = SourceProvider.LoadPackageSources() .Where(p => p.IsEnabled) .ToList(); IList <Configuration.PackageSource> packageSources; if (Source.Count > 0) { packageSources = Source .Select(s => Common.PackageSourceProviderExtensions.ResolveSource(configurationSources, s)) .ToList(); } else { packageSources = configurationSources; } var sourceRepositoryProvider = new CommandLineSourceRepositoryProvider(SourceProvider); var listCommandResourceTasks = packageSources .Select(source => { var sourceRepository = sourceRepositoryProvider.CreateRepository(source); return(sourceRepository.GetResourceAsync <ListCommandResource>()); }) .ToList(); var listCommandResources = await Task.WhenAll(listCommandResourceTasks); var listEndpoints = packageSources.Zip( listCommandResources, (p, l) => new KeyValuePair <Configuration.PackageSource, string>(p, l?.GetListEndpoint())); var partitioned = listEndpoints.ToLookup(kv => kv.Value != null); foreach (var packageSource in partitioned[key: false].Select(kv => kv.Key)) { var message = string.Format( LocalizedResourceManager.GetString("ListCommand_ListNotSupported"), packageSource.Source); Console.LogWarning(message); } return(partitioned[key : true].ToList()); }
private static async Task<IList<string>> GetListEndpointsAsync(IPackageSourceProvider sourceProvider) { var configurationSources = sourceProvider.LoadPackageSources() .Where(p => p.IsEnabled) .ToList(); var sourceRepositoryProvider = new CommandLineSourceRepositoryProvider(sourceProvider); var listCommandResourceTasks = configurationSources.Select(source => sourceRepositoryProvider.CreateRepository(source)).Select(sourceRepository => sourceRepository.GetResourceAsync<ListCommandResource>()).ToList(); var listCommandResources = await Task.WhenAll(listCommandResourceTasks).ConfigureAwait(false); var listEndpoints = new List<string>(); foreach (var listCommandResource in listCommandResources) { string listEndpoint = null; if (listCommandResource != null) { listEndpoint = listCommandResource.GetListEndpoint(); } if (listEndpoint != null) { listEndpoints.Add(listEndpoint); } } return listEndpoints; }