diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-27 01:58:23 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-27 01:58:23 +0700 |
commit | e71fe27c302d36e6355d9da12f3d9ec51540825a (patch) | |
tree | 6aa065f627d14e659e68ae0cbe355b656af3e40f /crypto/src/util/collections/CollectionUtilities.cs | |
parent | Add CrlID.GetInstance methods, obsolete public constructor (diff) | |
download | BouncyCastle.NET-ed25519-e71fe27c302d36e6355d9da12f3d9ec51540825a.tar.xz |
Misc. cleanup after bc-fips-csharp updates
Diffstat (limited to 'crypto/src/util/collections/CollectionUtilities.cs')
-rw-r--r-- | crypto/src/util/collections/CollectionUtilities.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crypto/src/util/collections/CollectionUtilities.cs b/crypto/src/util/collections/CollectionUtilities.cs index 26b3f2a1d..a1fb0e949 100644 --- a/crypto/src/util/collections/CollectionUtilities.cs +++ b/crypto/src/util/collections/CollectionUtilities.cs @@ -31,6 +31,19 @@ namespace Org.BouncyCastle.Utilities.Collections return new StoreImpl<T>(contents); } + public static T GetFirstOrNull<T>(IEnumerable<T> e) + where T : class + { + if (e != null) + { + foreach (var t in e) + { + return t; + } + } + return null; + } + public static T GetValueOrKey<T>(IDictionary<T, T> d, T k) { return d.TryGetValue(k, out var v) ? v : k; |