summary refs log tree commit diff
path: root/crypto/src/asn1/cmp/ProtectedPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/cmp/ProtectedPart.cs')
-rw-r--r--crypto/src/asn1/cmp/ProtectedPart.cs50
1 files changed, 20 insertions, 30 deletions
diff --git a/crypto/src/asn1/cmp/ProtectedPart.cs b/crypto/src/asn1/cmp/ProtectedPart.cs
index ed90708f9..fc83ac6c6 100644
--- a/crypto/src/asn1/cmp/ProtectedPart.cs
+++ b/crypto/src/asn1/cmp/ProtectedPart.cs
@@ -1,47 +1,37 @@
-using System;
-
-using Org.BouncyCastle.Utilities;
-
 namespace Org.BouncyCastle.Asn1.Cmp
 {
 	public class ProtectedPart
 		: Asn1Encodable
 	{
-		private readonly PkiHeader header;
-		private readonly PkiBody body;
-		
-		private ProtectedPart(Asn1Sequence seq)
-		{
-			header = PkiHeader.GetInstance(seq[0]);
-			body = PkiBody.GetInstance(seq[1]);
-		}
+        public static ProtectedPart GetInstance(object obj)
+        {
+			if (obj is ProtectedPart protectedPart)
+				return protectedPart;
 
-		public static ProtectedPart GetInstance(object obj)
-		{
-			if (obj is ProtectedPart)
-				return (ProtectedPart)obj;
+			if (obj != null)
+				return new ProtectedPart(Asn1Sequence.GetInstance(obj));
 
-			if (obj is Asn1Sequence)
-				return new ProtectedPart((Asn1Sequence)obj);
+			return null;
+        }
 
-            throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), "obj");
-		}
+        private readonly PkiHeader m_header;
+		private readonly PkiBody m_body;
 
-		public ProtectedPart(PkiHeader header, PkiBody body)
+		private ProtectedPart(Asn1Sequence seq)
 		{
-			this.header = header;
-			this.body = body;
+			m_header = PkiHeader.GetInstance(seq[0]);
+			m_body = PkiBody.GetInstance(seq[1]);
 		}
 
-		public virtual PkiHeader Header
+		public ProtectedPart(PkiHeader header, PkiBody body)
 		{
-			get { return header; }
+			m_header = header;
+			m_body = body;
 		}
 
-		public virtual PkiBody Body
-		{
-			get { return body; }
-		}
+		public virtual PkiHeader Header => m_header;
+
+		public virtual PkiBody Body => m_body;
 
 		/**
 		 * <pre>
@@ -54,7 +44,7 @@ namespace Org.BouncyCastle.Asn1.Cmp
 		 */
 		public override Asn1Object ToAsn1Object()
 		{
-			return new DerSequence(header, body);
+			return new DerSequence(m_header, m_body);
 		}
 	}
 }