refactor(RSACryptographerList): entfernt
This commit is contained in:
parent
2f0c6a905a
commit
b02f93b38d
@ -20,8 +20,5 @@ namespace DigitalData.Core.Security.Cryptographer
|
||||
cryptographer = cryptographers.SingleOrDefault(c => c.Issuer == issuer && c.Audience == audience);
|
||||
return cryptographer is not null;
|
||||
}
|
||||
|
||||
public static RSACryptographerList<TRSACryptographer> ToCryptographerList<TRSACryptographer>(this IEnumerable<TRSACryptographer> cryptographers, Func<TRSACryptographer, string> keyGenerator) where TRSACryptographer : IRSACryptographer
|
||||
=> new(keyGenerator: keyGenerator, cryptographers: cryptographers);
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
using DigitalData.Core.Abstractions.Security;
|
||||
using System.Collections;
|
||||
|
||||
namespace DigitalData.Core.Security.Cryptographer
|
||||
{
|
||||
public class RSACryptographerList<TRSACryptographer> : IEnumerable<TRSACryptographer> where TRSACryptographer : IRSACryptographer
|
||||
{
|
||||
private readonly Func<TRSACryptographer, string> _keyGenerator;
|
||||
|
||||
private readonly IEnumerable<TRSACryptographer> _cryptographers;
|
||||
|
||||
internal RSACryptographerList(Func<TRSACryptographer, string> keyGenerator, IEnumerable<TRSACryptographer> cryptographers)
|
||||
{
|
||||
_keyGenerator = keyGenerator;
|
||||
_cryptographers = cryptographers;
|
||||
}
|
||||
|
||||
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 bool TryGet(string key, out TRSACryptographer? cryptographer)
|
||||
{
|
||||
cryptographer = _cryptographers.SingleOrDefault(crypt => _keyGenerator(crypt) == key);
|
||||
return cryptographer is not null;
|
||||
}
|
||||
|
||||
public IEnumerator<TRSACryptographer> GetEnumerator() => _cryptographers.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user