ok now it works

This commit is contained in:
zznty
2024-10-22 21:11:33 +07:00
parent 8f7fef8857
commit bf3eaedf62
46 changed files with 1150 additions and 244 deletions

View 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);