From dc8b86c13c769e6de9a5c38e3c67921b034a2394 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 14 Jul 2023 15:07:49 +0700 Subject: Refactoring in Asn1 --- crypto/src/asn1/x509/Holder.cs | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'crypto/src/asn1/x509/Holder.cs') diff --git a/crypto/src/asn1/x509/Holder.cs b/crypto/src/asn1/x509/Holder.cs index 90df75a0f..3da57f70f 100644 --- a/crypto/src/asn1/x509/Holder.cs +++ b/crypto/src/asn1/x509/Holder.cs @@ -42,33 +42,26 @@ namespace Org.BouncyCastle.Asn1.X509 internal readonly ObjectDigestInfo objectDigestInfo; private readonly int version; - public static Holder GetInstance( - object obj) + public static Holder GetInstance(object obj) { - if (obj is Holder) - { - return (Holder) obj; - } + if (obj is Holder holder) + return holder; - if (obj is Asn1Sequence) - { - return new Holder((Asn1Sequence) obj); - } + if (obj is Asn1Sequence sequence) + return new Holder(sequence); - if (obj is Asn1TaggedObject) - { - return new Holder((Asn1TaggedObject) obj); - } + if (obj is Asn1TaggedObject taggedObject) + return new Holder(taggedObject); throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj"); - } + } - /** + /** * Constructor for a holder for an v1 attribute certificate. * * @param tagObj The ASN.1 tagged holder object. */ - public Holder( + public Holder( Asn1TaggedObject tagObj) { switch (tagObj.TagNo) -- cgit 1.4.1