
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m38s
Build / Build Nuget package (NuGet) (push) Successful in 2m24s
Build / Build Nuget package (CringePlugins) (push) Successful in 2m48s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m29s
Build / Build Launcher (push) Successful in 3m50s
17 lines
551 B
C#
17 lines
551 B
C#
using System.Collections.Immutable;
|
|
|
|
namespace NuGet;
|
|
|
|
public class PackageSourceMapping(ImmutableArray<PackageSource> sources)
|
|
{
|
|
private readonly ImmutableArray<(string pattern, Task<NuGetClient> client)> _clients = [
|
|
..sources.Select(b =>
|
|
(b.Pattern,
|
|
NuGetClient.CreateFromIndexUrlAsync(b.Url)))
|
|
];
|
|
|
|
public Task<NuGetClient> GetClientAsync(string packageId) =>
|
|
_clients.FirstOrDefault(b => packageId.StartsWith(b.pattern)).client;
|
|
}
|
|
|
|
public record PackageSource(string Pattern, string Url); |