summary refs log tree commit diff
path: root/crypto/src/asn1/crmf/CertReqMessages.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/crmf/CertReqMessages.cs')
-rw-r--r--crypto/src/asn1/crmf/CertReqMessages.cs41
1 files changed, 17 insertions, 24 deletions
diff --git a/crypto/src/asn1/crmf/CertReqMessages.cs b/crypto/src/asn1/crmf/CertReqMessages.cs
index d49b90fe3..fc01fb99d 100644
--- a/crypto/src/asn1/crmf/CertReqMessages.cs
+++ b/crypto/src/asn1/crmf/CertReqMessages.cs
@@ -1,49 +1,42 @@
-using System;
-
-using Org.BouncyCastle.Utilities;
-
 namespace Org.BouncyCastle.Asn1.Crmf
 {
     public class CertReqMessages
         : Asn1Encodable
     {
-        private readonly Asn1Sequence content;
-
-        private CertReqMessages(Asn1Sequence seq)
+        public static CertReqMessages GetInstance(object obj)
         {
-            content = seq;
+            if (obj == null)
+                return null;
+            if (obj is CertReqMessages certReqMessages)
+                return certReqMessages;
+            return new CertReqMessages(Asn1Sequence.GetInstance(obj));
         }
 
-        public static CertReqMessages GetInstance(object obj)
+        public static CertReqMessages GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
         {
-            if (obj is CertReqMessages)
-                return (CertReqMessages)obj;
-
-            if (obj is Asn1Sequence)
-                return new CertReqMessages((Asn1Sequence)obj);
-
-            throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj");
+            return new CertReqMessages(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
         }
 
-		public CertReqMessages(params CertReqMsg[] msgs)
+        private readonly Asn1Sequence m_content;
+
+        private CertReqMessages(Asn1Sequence seq)
         {
-            content = new DerSequence(msgs);
+            m_content = seq;
         }
 
-        public virtual CertReqMsg[] ToCertReqMsgArray()
+        public CertReqMessages(params CertReqMsg[] msgs)
         {
-            return content.MapElements(CertReqMsg.GetInstance);
+            m_content = new DerSequence(msgs);
         }
 
+        public virtual CertReqMsg[] ToCertReqMsgArray() => m_content.MapElements(CertReqMsg.GetInstance);
+
         /**
          * <pre>
          * CertReqMessages ::= SEQUENCE SIZE (1..MAX) OF CertReqMsg
          * </pre>
          * @return a basic ASN.1 object representation.
          */
-        public override Asn1Object ToAsn1Object()
-        {
-            return content;
-        }
+        public override Asn1Object ToAsn1Object() => m_content;
     }
 }