up
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled

This commit is contained in:
StellaOps Bot
2025-11-26 07:47:08 +02:00
parent 56e2f64d07
commit 1c782897f7
184 changed files with 8991 additions and 649 deletions

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace StellaOps.Cryptography;
public sealed class CryptoRegistryProfiles
{
public IReadOnlyList<string> PreferredProviders { get; }
public string ActiveProfile { get; }
public IReadOnlyDictionary<string, IReadOnlyList<string>> Profiles { get; }
public CryptoRegistryProfiles(
IEnumerable<string> preferredProviders,
string activeProfile,
IDictionary<string, IReadOnlyList<string>> profiles)
{
PreferredProviders = (preferredProviders ?? throw new ArgumentNullException(nameof(preferredProviders)))
.Where(p => !string.IsNullOrWhiteSpace(p))
.Select(p => p.Trim())
.ToArray();
ActiveProfile = string.IsNullOrWhiteSpace(activeProfile)
? throw new ArgumentException("Active profile is required", nameof(activeProfile))
: activeProfile.Trim();
Profiles = new ReadOnlyDictionary<string, IReadOnlyList<string>>(profiles ??
throw new ArgumentNullException(nameof(profiles)));
}
public IReadOnlyList<string> ResolvePreferredOrder(string? profileName = null)
{
if (!string.IsNullOrWhiteSpace(profileName) && Profiles.TryGetValue(profileName!, out var specific))
{
return specific;
}
if (Profiles.TryGetValue(ActiveProfile, out var active))
{
return active;
}
return PreferredProviders;
}
}