From 016d8bdcf2a07eadc4a07c945cae535289acd5fe Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 5 Dec 2024 14:36:28 +0100 Subject: [PATCH] =?UTF-8?q?feat(RSACryptographerList):=20Hinzuf=C3=BCgen?= =?UTF-8?q?=20der=20Methode=20try=20get=20mit=20dem=20Wort=20out-key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cryptographer/RSACryptographerList.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs b/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs index f7ab7a7..6bfada7 100644 --- a/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs +++ b/DigitalData.Core.Security/Cryptographer/RSACryptographerList.cs @@ -19,6 +19,12 @@ namespace DigitalData.Core.Security.Cryptographer => _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 GetEnumerator() => _cryptographers.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();