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