/// <summary> /// Create NuGet resource providers. /// </summary> /// <param name="providerVersions">The provider version(s) to create.</param> /// <returns>A list of resource providers.</returns> public static List <Lazy <INuGetResourceProvider> > CreateResourceProviders(NuGetResourceProviderVersions providerVersions = NuGetResourceProviderVersions.Current) { var providers = new List <Lazy <INuGetResourceProvider> >(); if ((providerVersions & NuGetResourceProviderVersions.V3) != 0) { // v3 API support providers.AddRange(Repository.Provider.GetCoreV3()); } return(providers); }
/// <summary> /// Create v3 resource repositories for the specified package source. /// </summary> /// <param name="packageSource">The <see cref="PackageSource"/>.</param> /// <param name="providerVersions">A <see cref="NuGetResourceProviderVersions"/> value indicating which versions of the NuGet resource providers to use.</param> /// <returns>The configured <see cref="SourceRepository"/> instance.</returns> public static SourceRepository CreateResourceRepository(this PackageSource packageSource, NuGetResourceProviderVersions providerVersions = NuGetResourceProviderVersions.Current) { if (packageSource == null) { throw new ArgumentNullException(nameof(packageSource)); } return(packageSource.CreateResourceRepository( providers: CreateResourceProviders(providerVersions) )); }
/// <summary> /// Create resource repositories for the specified package source. /// </summary> /// <param name="packageSources">The <see cref="PackageSource"/>s.</param> /// <param name="providerVersions">The NuGet provider version(s) to use.</param> /// <returns>A list of configured <see cref="SourceRepository"/> instances (one for each <see cref="PackageSource"/>).</returns> public static List <SourceRepository> CreateResourceRepositories(this IEnumerable <PackageSource> packageSources, NuGetResourceProviderVersions providerVersions = NuGetResourceProviderVersions.Current) { if (packageSources == null) { throw new ArgumentNullException(nameof(packageSources)); } List <SourceRepository> sourceRepositories = new List <SourceRepository>(); List <Lazy <INuGetResourceProvider> > providers = CreateResourceProviders(providerVersions); foreach (PackageSource packageSource in packageSources) { SourceRepository sourceRepository = new SourceRepository(packageSource, providers); sourceRepositories.Add(sourceRepository); } return(sourceRepositories); }