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