diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-02-21 18:32:24 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-02-21 18:32:24 +0700 |
commit | aa67c1309df1bfd1d9eac195fb82d9c75984901c (patch) | |
tree | ce982075f278160c91badfb5e9159fd1e641faa3 /crypto/src | |
parent | Refactoring (diff) | |
download | BouncyCastle.NET-ed25519-aa67c1309df1bfd1d9eac195fb82d9c75984901c.tar.xz |
Add utility method
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/openpgp/PgpObjectFactory.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/crypto/src/openpgp/PgpObjectFactory.cs b/crypto/src/openpgp/PgpObjectFactory.cs index c5c6fcb68..c31cd221c 100644 --- a/crypto/src/openpgp/PgpObjectFactory.cs +++ b/crypto/src/openpgp/PgpObjectFactory.cs @@ -139,5 +139,24 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp } return result; } - } + + /// <summary> + /// Read all available objects, returning only those that are assignable to the specified type. + /// </summary> + /// <param name="type">The type of objects to return. All other objects are ignored.</param> + /// <returns>An <c>IList</c> containing the filtered objects from this factory, in order.</returns> + public IList FilterPgpObjects(Type type) + { + IList result = Platform.CreateArrayList(); + PgpObject pgpObject; + while ((pgpObject = NextPgpObject()) != null) + { + if (type.IsAssignableFrom(pgpObject.GetType())) + { + result.Add(pgpObject); + } + } + return result; + } + } } |