summary refs log tree commit diff
path: root/crypto/src/asn1/x509/DistributionPointName.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/x509/DistributionPointName.cs')
-rw-r--r--crypto/src/asn1/x509/DistributionPointName.cs82
1 files changed, 30 insertions, 52 deletions
diff --git a/crypto/src/asn1/x509/DistributionPointName.cs b/crypto/src/asn1/x509/DistributionPointName.cs
index bca54fa06..bdb7219be 100644
--- a/crypto/src/asn1/x509/DistributionPointName.cs
+++ b/crypto/src/asn1/x509/DistributionPointName.cs
@@ -1,8 +1,5 @@
-using System;
 using System.Text;
 
-using Org.BouncyCastle.Utilities;
-
 namespace Org.BouncyCastle.Asn1.X509
 {
     /**
@@ -17,90 +14,71 @@ namespace Org.BouncyCastle.Asn1.X509
     public class DistributionPointName
         : Asn1Encodable, IAsn1Choice
     {
-        internal readonly Asn1Encodable	name;
-        internal readonly int			type;
-
-		public const int FullName					= 0;
-        public const int NameRelativeToCrlIssuer	= 1;
+        public const int FullName = 0;
+        public const int NameRelativeToCrlIssuer = 1;
 
-		public static DistributionPointName GetInstance(
-            Asn1TaggedObject	obj,
-            bool				explicitly)
+		public static DistributionPointName GetInstance(object obj)
         {
-            return GetInstance(Asn1TaggedObject.GetInstance(obj, true));
-        }
-
-		public static DistributionPointName GetInstance(
-            object obj)
-        {
-            if (obj == null || obj is DistributionPointName)
-            {
-                return (DistributionPointName) obj;
-            }
-
-			if (obj is Asn1TaggedObject)
-            {
-                return new DistributionPointName((Asn1TaggedObject) obj);
-            }
-
-            throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
+            if (obj == null)
+                return null;
+            if (obj is DistributionPointName distributionPointName)
+                return distributionPointName;
+            return new DistributionPointName(Asn1TaggedObject.GetInstance(obj));
 		}
 
-        public DistributionPointName(
-            int				type,
-            Asn1Encodable	name)
+		public static DistributionPointName GetInstance(Asn1TaggedObject obj, bool explicitly)
         {
-            this.type = type;
-            this.name = name;
+            return GetInstance(Asn1TaggedObject.GetInstance(obj, true));
         }
 
-		public DistributionPointName(
-			GeneralNames name)
-			:	this(FullName, name)
-		{
-		}
+        private readonly Asn1Encodable m_name;
+        private readonly int m_type;
 
-		public int PointType
+        public DistributionPointName(GeneralNames name)
+            : this(FullName, name)
         {
-			get { return type; }
         }
 
-		public Asn1Encodable Name
+        public DistributionPointName(int type, Asn1Encodable name)
         {
-			get { return name; }
+            m_type = type;
+            m_name = name;
         }
 
-		public DistributionPointName(
-            Asn1TaggedObject obj)
+		public int PointType => m_type;
+
+		public Asn1Encodable Name => m_name;
+
+		public DistributionPointName(Asn1TaggedObject obj)
         {
-            this.type = obj.TagNo;
+            m_type = obj.TagNo;
 
-			if (type == FullName)
+			if (m_type == FullName)
             {
-                this.name = GeneralNames.GetInstance(obj, false);
+                m_name = GeneralNames.GetInstance(obj, false);
             }
             else
             {
-                this.name = Asn1Set.GetInstance(obj, false);
+                m_name = Asn1Set.GetInstance(obj, false);
             }
         }
 
 		public override Asn1Object ToAsn1Object()
         {
-            return new DerTaggedObject(false, type, name);
+            return new DerTaggedObject(false, m_type, m_name);
         }
 
 		public override string ToString()
 		{
 			StringBuilder buf = new StringBuilder();
 			buf.AppendLine("DistributionPointName: [");
-			if (type == FullName)
+			if (m_type == FullName)
 			{
-				AppendObject(buf, "fullName", name.ToString());
+				AppendObject(buf, "fullName", m_name.ToString());
 			}
 			else
 			{
-				AppendObject(buf, "nameRelativeToCRLIssuer", name.ToString());
+				AppendObject(buf, "nameRelativeToCRLIssuer", m_name.ToString());
 			}
 			buf.AppendLine("]");
 			return buf.ToString();