diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-14 15:07:49 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-14 15:07:49 +0700 |
commit | dc8b86c13c769e6de9a5c38e3c67921b034a2394 (patch) | |
tree | b79eb20bc7ed797e7624ccb5ceb8293ed429751e /crypto/src/asn1/x509/X509Extensions.cs | |
parent | Refactor using MapElements (diff) | |
download | BouncyCastle.NET-ed25519-dc8b86c13c769e6de9a5c38e3c67921b034a2394.tar.xz |
Refactoring in Asn1
Diffstat (limited to '')
-rw-r--r-- | crypto/src/asn1/x509/X509Extensions.cs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/crypto/src/asn1/x509/X509Extensions.cs b/crypto/src/asn1/x509/X509Extensions.cs index 62291a829..390bf46b7 100644 --- a/crypto/src/asn1/x509/X509Extensions.cs +++ b/crypto/src/asn1/x509/X509Extensions.cs @@ -203,28 +203,24 @@ namespace Org.BouncyCastle.Asn1.X509 return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } - public static X509Extensions GetInstance( - object obj) + public static X509Extensions GetInstance(object obj) { - if (obj == null || obj is X509Extensions) - { - return (X509Extensions) obj; - } + if (obj == null) + return null; - if (obj is Asn1Sequence) - { - return new X509Extensions((Asn1Sequence) obj); - } + if (obj is X509Extensions x509Extensions) + return x509Extensions; - if (obj is Asn1TaggedObject) - { - return GetInstance(((Asn1TaggedObject) obj).GetObject()); - } + if (obj is Asn1Sequence sequence) + return new X509Extensions(sequence); + + if (obj is Asn1TaggedObject taggedObject) + return GetInstance(taggedObject.GetObject()); throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj"); - } + } - /** + /** * Constructor from Asn1Sequence. * * the extensions are a list of constructed sequences, either with (Oid, OctetString) or (Oid, Boolean, OctetString) |