summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/openpgp/PgpObjectFactory.cs21
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;
+        }
+    }
 }