feat(RSACryptographerList): Erstellt, um die Cryptographer-Liste sowohl als Wörterbuch als auch als IEnumerable zu verwenden
This commit is contained in:
parent
b8fb45d4a3
commit
35e2fef046
@ -0,0 +1,24 @@
|
||||
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);
|
||||
|
||||
public IEnumerator<TRSACryptographer> GetEnumerator() => _cryptographers.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user