diff options
Diffstat (limited to 'crypto/src/asn1/DerBMPString.cs')
-rw-r--r-- | crypto/src/asn1/DerBMPString.cs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/crypto/src/asn1/DerBMPString.cs b/crypto/src/asn1/DerBMPString.cs index a289eed1b..284a4b830 100644 --- a/crypto/src/asn1/DerBMPString.cs +++ b/crypto/src/asn1/DerBMPString.cs @@ -31,21 +31,23 @@ namespace Org.BouncyCastle.Asn1 */ public static DerBmpString GetInstance(object obj) { - if (obj == null || obj is DerBmpString) - { - return (DerBmpString)obj; - } - else if (obj is IAsn1Convertible) + if (obj == null) + return null; + + if (obj is DerBmpString derBmpString) + return derBmpString; + + if (obj is IAsn1Convertible asn1Convertible) { - Asn1Object asn1Object = ((IAsn1Convertible)obj).ToAsn1Object(); - if (asn1Object is DerBmpString) - return (DerBmpString)asn1Object; + Asn1Object asn1Object = asn1Convertible.ToAsn1Object(); + if (asn1Object is DerBmpString converted) + return converted; } - else if (obj is byte[]) + else if (obj is byte[] bytes) { try { - return (DerBmpString)Meta.Instance.FromByteArray((byte[])obj); + return (DerBmpString)Meta.Instance.FromByteArray(bytes); } catch (IOException e) { |