<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.0" />

Iso4217CurrencyCode

using System; namespace Org.BouncyCastle.Asn1.X509.Qualified { public class Iso4217CurrencyCode : Asn1Encodable, IAsn1Choice { internal const int AlphabeticMaxSize = 3; internal const int NumericMinSize = 1; internal const int NumericMaxSize = 999; private readonly Asn1Encodable m_obj; public bool IsAlphabetic => m_obj is DerPrintableString; public string Alphabetic => ((DerPrintableString)m_obj).GetString(); public int Numeric => ((DerInteger)m_obj).IntValueExact; public static Iso4217CurrencyCode GetInstance(object obj) { return Asn1Utilities.GetInstanceChoice(obj, GetOptional); } public static Iso4217CurrencyCode GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { return Asn1Utilities.GetInstanceChoice(taggedObject, declaredExplicit, GetInstance); } public static Iso4217CurrencyCode GetOptional(Asn1Encodable element) { if (element == null) throw new ArgumentNullException("element"); Iso4217CurrencyCode iso4217CurrencyCode = element as Iso4217CurrencyCode; if (iso4217CurrencyCode != null) return iso4217CurrencyCode; DerPrintableString optional = DerPrintableString.GetOptional(element); if (optional != null) return new Iso4217CurrencyCode(optional.GetString()); DerInteger optional2 = DerInteger.GetOptional(element); if (optional2 != null) return new Iso4217CurrencyCode(optional2.IntValueExact); return null; } public static Iso4217CurrencyCode GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) { return Asn1Utilities.GetTaggedChoice(taggedObject, declaredExplicit, GetInstance); } public Iso4217CurrencyCode(int numeric) { if (numeric > 999 || numeric < 1) { string[] obj = new string[5] { "wrong size in numeric code : not in (", null, null, null, null }; int num = 1; obj[1] = num.ToString(); obj[2] = ".."; num = 999; obj[3] = num.ToString(); obj[4] = ")"; throw new ArgumentException(string.Concat(obj)); } m_obj = new DerInteger(numeric); } public Iso4217CurrencyCode(string alphabetic) { if (alphabetic.Length > 3) throw new ArgumentException("wrong size in alphabetic code : max size is " + 3.ToString()); m_obj = new DerPrintableString(alphabetic); } public override Asn1Object ToAsn1Object() { return m_obj.ToAsn1Object(); } } }