ok now it works
This commit is contained in:
16
NuGet/PackageSourceMapping.cs
Normal file
16
NuGet/PackageSourceMapping.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace NuGet;
|
||||
|
||||
public class PackageSourceMapping(ImmutableArray<PackageSource> sources)
|
||||
{
|
||||
private readonly ImmutableDictionary<string, Task<NuGetClient>> _clients = sources.Select(b =>
|
||||
new KeyValuePair<string, Task<NuGetClient>>(b.Pattern,
|
||||
NuGetClient.CreateFromIndexUrlAsync(b.Url)))
|
||||
.ToImmutableDictionary();
|
||||
|
||||
public Task<NuGetClient> GetClientAsync(string packageId) =>
|
||||
_clients.FirstOrDefault(b => packageId.StartsWith(b.Key)).Value;
|
||||
}
|
||||
|
||||
public record PackageSource(string Pattern, string Url);
|
Reference in New Issue
Block a user