summary refs log tree commit diff
path: root/crypto/src/asn1/esf/CrlListID.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/esf/CrlListID.cs')
-rw-r--r--crypto/src/asn1/esf/CrlListID.cs61
1 files changed, 25 insertions, 36 deletions
diff --git a/crypto/src/asn1/esf/CrlListID.cs b/crypto/src/asn1/esf/CrlListID.cs
index d3c4365c5..1ee58aebc 100644
--- a/crypto/src/asn1/esf/CrlListID.cs
+++ b/crypto/src/asn1/esf/CrlListID.cs
@@ -17,71 +17,60 @@ namespace Org.BouncyCastle.Asn1.Esf
 	public class CrlListID
 		: Asn1Encodable
 	{
-		private readonly Asn1Sequence crls;
+		private readonly Asn1Sequence m_crls;
 
-		public static CrlListID GetInstance(
-			object obj)
+		public static CrlListID GetInstance(object obj)
 		{
-			if (obj == null || obj is CrlListID)
-				return (CrlListID) obj;
+			if (obj == null)
+				return null;
 
-			if (obj is Asn1Sequence)
-				return new CrlListID((Asn1Sequence) obj);
+			if (obj is CrlListID crlListID)
+				return crlListID;
 
-			throw new ArgumentException(
-				"Unknown object in 'CrlListID' factory: "
-                    + Platform.GetTypeName(obj),
-				"obj");
+			if (obj is Asn1Sequence asn1Sequence)
+				return new CrlListID(asn1Sequence);
+
+			throw new ArgumentException("Unknown object in 'CrlListID' factory: " + Platform.GetTypeName(obj),
+				nameof(obj));
 		}
 
-		private CrlListID(
-			Asn1Sequence seq)
+		private CrlListID(Asn1Sequence seq)
 		{
 			if (seq == null)
-				throw new ArgumentNullException("seq");
+				throw new ArgumentNullException(nameof(seq));
 			if (seq.Count != 1)
-				throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
+				throw new ArgumentException("Bad sequence size: " + seq.Count, nameof(seq));
 
-			this.crls = (Asn1Sequence) seq[0].ToAsn1Object();
+			m_crls = (Asn1Sequence)seq[0].ToAsn1Object();
 
-			foreach (Asn1Encodable ae in this.crls)
-			{
-				CrlValidatedID.GetInstance(ae.ToAsn1Object());
-			}
+			// Validate
+			m_crls.MapElements(element => CrlValidatedID.GetInstance(element.ToAsn1Object()));
 		}
 
-		public CrlListID(
-			params CrlValidatedID[] crls)
+		public CrlListID(params CrlValidatedID[] crls)
 		{
 			if (crls == null)
-				throw new ArgumentNullException("crls");
+				throw new ArgumentNullException(nameof(crls));
 
-			this.crls = new DerSequence(crls);
+			this.m_crls = new DerSequence(crls);
 		}
 
-		public CrlListID(
-			IEnumerable<CrlValidatedID> crls)
+		public CrlListID(IEnumerable<CrlValidatedID> crls)
 		{
 			if (crls == null)
-				throw new ArgumentNullException("crls");
+                throw new ArgumentNullException(nameof(crls));
 
-			this.crls = new DerSequence(
-				Asn1EncodableVector.FromEnumerable(crls));
+            this.m_crls = new DerSequence(Asn1EncodableVector.FromEnumerable(crls));
 		}
 
 		public CrlValidatedID[] GetCrls()
 		{
-			CrlValidatedID[] result = new CrlValidatedID[crls.Count];
-			for (int i = 0; i < crls.Count; ++i)
-			{
-				result[i] = CrlValidatedID.GetInstance(crls[i].ToAsn1Object());
-			}
-			return result;
+            return m_crls.MapElements(element => CrlValidatedID.GetInstance(element.ToAsn1Object()));
 		}
 
 		public override Asn1Object ToAsn1Object()
 		{
-			return new DerSequence(crls);
+			return new DerSequence(m_crls);
 		}
 	}
 }