feat(RSACryptographerList): Die Ausgabe der Indexer-Methode ist nicht null und wirft eine Ausnahme, wenn sie nicht gefunden wird.
This commit is contained in:
parent
c96af25e23
commit
738005f5dc
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
public static TRSACryptographer Get<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers, string issuer, string audience) where TRSACryptographer : RSACryptographer
|
public static TRSACryptographer Get<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers, string issuer, string audience) where TRSACryptographer : RSACryptographer
|
||||||
=> cryptographers.Where(c => c.Issuer == issuer && c.Audience == audience).SingleOrDefault()
|
=> cryptographers.Where(c => c.Issuer == issuer && c.Audience == audience).SingleOrDefault()
|
||||||
?? throw new InvalidOperationException($"No {cryptographers.GetTypeName()} found with Issuer: {issuer} and Audience: {audience}");
|
?? throw new InvalidOperationException($"No {typeof(TRSACryptographer).GetType().Name.TrimStart('I')} found with Issuer: {issuer} and Audience: {audience}.");
|
||||||
|
|
||||||
public static bool TryGet<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers, string issuer, string audience, out TRSACryptographer? cryptographer) where TRSACryptographer : RSACryptographer
|
public static bool TryGet<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers, string issuer, string audience, out TRSACryptographer? cryptographer) where TRSACryptographer : RSACryptographer
|
||||||
{
|
{
|
||||||
@ -20,10 +20,5 @@
|
|||||||
|
|
||||||
public static RSACryptographerList<TRSACryptographer> ToCryptographerList<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers, Func<TRSACryptographer, string> keyGenerator) where TRSACryptographer : RSACryptographer
|
public static RSACryptographerList<TRSACryptographer> ToCryptographerList<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers, Func<TRSACryptographer, string> keyGenerator) where TRSACryptographer : RSACryptographer
|
||||||
=> new(keyGenerator: keyGenerator, cryptographers: cryptographers);
|
=> new(keyGenerator: keyGenerator, cryptographers: cryptographers);
|
||||||
|
|
||||||
private static string GetTypeName<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers) where TRSACryptographer : RSACryptographer
|
|
||||||
=> typeof(TRSACryptographer).GetType().Name.TrimStart(InterfaceIdentifierChar);
|
|
||||||
|
|
||||||
private static readonly char InterfaceIdentifierChar = 'I';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,7 +15,9 @@ namespace DigitalData.Core.Security.Cryptographer
|
|||||||
_cryptographers = cryptographers;
|
_cryptographers = cryptographers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TRSACryptographer? this[string key] => _cryptographers.SingleOrDefault(crypt => _keyGenerator(crypt) == key);
|
public TRSACryptographer this[string key]
|
||||||
|
=> _cryptographers.SingleOrDefault(crypt => _keyGenerator(crypt) == key)
|
||||||
|
?? throw new InvalidOperationException($"No {typeof(TRSACryptographer).GetType().Name.TrimStart('I')} found with Key: {key}.");
|
||||||
|
|
||||||
public IEnumerator<TRSACryptographer> GetEnumerator() => _cryptographers.GetEnumerator();
|
public IEnumerator<TRSACryptographer> GetEnumerator() => _cryptographers.GetEnumerator();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user