From 6e5206da62f412be2b27298c146b41271210e0d9 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 1 Jul 2024 19:41:12 +0700 Subject: Refactoring in Asn1.X500 --- crypto/src/asn1/x500/DirectoryString.cs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'crypto/src/asn1/x500/DirectoryString.cs') diff --git a/crypto/src/asn1/x500/DirectoryString.cs b/crypto/src/asn1/x500/DirectoryString.cs index c622113d4..aefb56512 100644 --- a/crypto/src/asn1/x500/DirectoryString.cs +++ b/crypto/src/asn1/x500/DirectoryString.cs @@ -4,11 +4,9 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Asn1.X500 { - public class DirectoryString + public class DirectoryString : Asn1Encodable, IAsn1Choice, IAsn1String { - private readonly DerStringBase str; - public static DirectoryString GetInstance(object obj) { if (obj == null) @@ -55,23 +53,20 @@ namespace Org.BouncyCastle.Asn1.X500 ?? (DerStringBase)null; } - private DirectoryString( - DerStringBase str) - { - this.str = str; - } + private readonly DerStringBase m_str; - public DirectoryString( - string str) + private DirectoryString(DerStringBase str) { - this.str = new DerUtf8String(str); + m_str = str; } - public string GetString() + public DirectoryString(string str) { - return str.GetString(); + m_str = new DerUtf8String(str); } + public string GetString() => m_str.GetString(); + /** *
 		 *  DirectoryString ::= CHOICE {
@@ -82,9 +77,6 @@ namespace Org.BouncyCastle.Asn1.X500
 		 *    bmpString                   BMPString (SIZE (1..MAX))  }
 		 * 
*/ - public override Asn1Object ToAsn1Object() - { - return str.ToAsn1Object(); - } + public override Asn1Object ToAsn1Object() => m_str.ToAsn1Object(); } } -- cgit 1.4.1