using DigitalData.Core.Abstractions.Security; using System.Collections; namespace DigitalData.Core.Security.Cryptographer { public class RSACryptographerList : IEnumerable where TRSACryptographer : IRSACryptographer { private readonly Func _keyGenerator; private readonly IEnumerable _cryptographers; internal RSACryptographerList(Func keyGenerator, IEnumerable cryptographers) { _keyGenerator = keyGenerator; _cryptographers = cryptographers; } public TRSACryptographer? this[string key] => _cryptographers.SingleOrDefault(crypt => _keyGenerator(crypt) == key); public IEnumerator GetEnumerator() => _cryptographers.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } }