summary refs log tree commit diff
path: root/crypto/src/asn1/cms/Attribute.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-20 19:01:12 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-20 19:01:12 +0700
commite5d77a0741bcc55088054b2ad4a91ab0508ac092 (patch)
tree816fc0d1139945ee9bfd22ca40f1e570e816a02f /crypto/src/asn1/cms/Attribute.cs
parentRefactoring in Asn1.Crmf (diff)
downloadBouncyCastle.NET-ed25519-e5d77a0741bcc55088054b2ad4a91ab0508ac092.tar.xz
Refactoring in Asn1.Cms
Diffstat (limited to 'crypto/src/asn1/cms/Attribute.cs')
-rw-r--r--crypto/src/asn1/cms/Attribute.cs34
1 files changed, 13 insertions, 21 deletions
diff --git a/crypto/src/asn1/cms/Attribute.cs b/crypto/src/asn1/cms/Attribute.cs
index 69ac44148..d42aefccb 100644
--- a/crypto/src/asn1/cms/Attribute.cs
+++ b/crypto/src/asn1/cms/Attribute.cs
@@ -1,33 +1,25 @@
-using System;
-
-using Org.BouncyCastle.Utilities;
-
 namespace Org.BouncyCastle.Asn1.Cms
 {
     public class Attribute
         : Asn1Encodable
     {
-        private DerObjectIdentifier	attrType;
-        private Asn1Set				attrValues;
-
-		/**
-        * return an Attribute object from the given object.
-        *
-        * @param o the object we want converted.
-        * @exception ArgumentException if the object cannot be converted.
-        */
-        public static Attribute GetInstance(
-            object obj)
+        public static Attribute GetInstance(object obj)
         {
-            if (obj == null || obj is Attribute)
-				return (Attribute) obj;
-
-			if (obj is Asn1Sequence)
-                return new Attribute((Asn1Sequence) obj);
+            if (obj == null)
+                return null;
+            if (obj is Attribute attribute)
+                return attribute;
+            return new Attribute(Asn1Sequence.GetInstance(obj));
+        }
 
-            throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
+        public static Attribute GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
+        {
+            return new Attribute(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
         }
 
+        private DerObjectIdentifier	attrType;
+        private Asn1Set				attrValues;
+
 		public Attribute(
             Asn1Sequence seq)
         {