summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-07-05 11:16:49 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-07-05 11:16:49 +0700
commit5523b0a211780cb7eb7a836c907c312fa119ba50 (patch)
tree915458a00236640de3d9d439fd3d15f935c7beed
parentEd448 updates from bc-java (diff)
downloadBouncyCastle.NET-ed25519-5523b0a211780cb7eb7a836c907c312fa119ba50.tar.xz
Overloads for params methods
-rw-r--r--crypto/src/asn1/Asn1EncodableVector.cs49
-rw-r--r--crypto/src/asn1/Asn1Sequence.cs12
-rw-r--r--crypto/src/asn1/BerSequence.cs10
-rw-r--r--crypto/src/asn1/DLSequence.cs8
-rw-r--r--crypto/src/asn1/DerSequence.cs10
5 files changed, 81 insertions, 8 deletions
diff --git a/crypto/src/asn1/Asn1EncodableVector.cs b/crypto/src/asn1/Asn1EncodableVector.cs
index b4249b7c0..f50eb6f98 100644
--- a/crypto/src/asn1/Asn1EncodableVector.cs
+++ b/crypto/src/asn1/Asn1EncodableVector.cs
@@ -42,6 +42,19 @@ namespace Org.BouncyCastle.Asn1
             this.copyOnWrite = false;
         }
 
+        public Asn1EncodableVector(Asn1Encodable element)
+            : this()
+        {
+            Add(element);
+        }
+
+        public Asn1EncodableVector(Asn1Encodable element1, Asn1Encodable element2)
+            : this()
+        {
+            Add(element1);
+            Add(element2);
+        }
+
         public Asn1EncodableVector(params Asn1Encodable[] v)
             : this()
         {
@@ -64,6 +77,12 @@ namespace Org.BouncyCastle.Asn1
             this.elementCount = minCapacity;
         }
 
+        public void Add(Asn1Encodable element1, Asn1Encodable element2)
+        {
+            Add(element1);
+            Add(element2);
+        }
+
         public void Add(params Asn1Encodable[] objs)
         {
             foreach (Asn1Encodable obj in objs)
@@ -72,15 +91,35 @@ namespace Org.BouncyCastle.Asn1
             }
         }
 
-        public void AddOptional(params Asn1Encodable[] objs)
+        public void AddOptional(Asn1Encodable element)
+        {
+            if (element != null)
+            {
+                Add(element);
+            }
+        }
+
+        public void AddOptional(Asn1Encodable element1, Asn1Encodable element2)
+        {
+            if (element1 != null)
+            {
+                Add(element1);
+            }
+            if (element2 != null)
+            {
+                Add(element2);
+            }
+        }
+
+        public void AddOptional(params Asn1Encodable[] elements)
         {
-            if (objs != null)
+            if (elements != null)
             {
-                foreach (Asn1Encodable obj in objs)
+                foreach (var element in elements)
                 {
-                    if (obj != null)
+                    if (element != null)
                     {
-                        Add(obj);
+                        Add(element);
                     }
                 }
             }
diff --git a/crypto/src/asn1/Asn1Sequence.cs b/crypto/src/asn1/Asn1Sequence.cs
index d164b32f1..3ceea4521 100644
--- a/crypto/src/asn1/Asn1Sequence.cs
+++ b/crypto/src/asn1/Asn1Sequence.cs
@@ -86,11 +86,21 @@ namespace Org.BouncyCastle.Asn1
         protected internal Asn1Sequence(Asn1Encodable element)
         {
             if (null == element)
-                throw new ArgumentNullException("element");
+                throw new ArgumentNullException(nameof(element));
 
             this.elements = new Asn1Encodable[]{ element };
         }
 
+        protected internal Asn1Sequence(Asn1Encodable element1, Asn1Encodable element2)
+        {
+            if (null == element1)
+                throw new ArgumentNullException(nameof(element1));
+            if (null == element2)
+                throw new ArgumentNullException(nameof(element2));
+
+            this.elements = new Asn1Encodable[]{ element1, element2 };
+        }
+
         protected internal Asn1Sequence(params Asn1Encodable[] elements)
         {
             if (Arrays.IsNullOrContainsNull(elements))
diff --git a/crypto/src/asn1/BerSequence.cs b/crypto/src/asn1/BerSequence.cs
index deed8fbb9..074359402 100644
--- a/crypto/src/asn1/BerSequence.cs
+++ b/crypto/src/asn1/BerSequence.cs
@@ -28,7 +28,15 @@ namespace Org.BouncyCastle.Asn1
 		{
 		}
 
-		public BerSequence(params Asn1Encodable[] elements)
+        /**
+		 * create a sequence containing two objects
+		 */
+        public BerSequence(Asn1Encodable element1, Asn1Encodable element2)
+            : base(element1, element2)
+        {
+        }
+
+        public BerSequence(params Asn1Encodable[] elements)
             : base(elements)
 		{
 		}
diff --git a/crypto/src/asn1/DLSequence.cs b/crypto/src/asn1/DLSequence.cs
index b3c21ece5..7f3a73f7b 100644
--- a/crypto/src/asn1/DLSequence.cs
+++ b/crypto/src/asn1/DLSequence.cs
@@ -28,6 +28,14 @@ namespace Org.BouncyCastle.Asn1
         {
         }
 
+        /**
+		 * create a sequence containing two objects
+		 */
+        public DLSequence(Asn1Encodable element1, Asn1Encodable element2)
+            : base(element1, element2)
+        {
+        }
+
         internal DLSequence(params Asn1Encodable[] elements)
             : base(elements)
         {
diff --git a/crypto/src/asn1/DerSequence.cs b/crypto/src/asn1/DerSequence.cs
index 2ac977fe0..01bef61d3 100644
--- a/crypto/src/asn1/DerSequence.cs
+++ b/crypto/src/asn1/DerSequence.cs
@@ -28,7 +28,15 @@ namespace Org.BouncyCastle.Asn1
 		{
 		}
 
-		public DerSequence(params Asn1Encodable[] elements)
+        /**
+		 * create a sequence containing two objects
+		 */
+        public DerSequence(Asn1Encodable element1, Asn1Encodable element2)
+            : base(element1, element2)
+        {
+        }
+
+        public DerSequence(params Asn1Encodable[] elements)
             : base(elements)
 		{
 		}