Inheritance: Org.BouncyCastle.Asn1.Asn1Encodable, IAsn1Choice
コード例 #1
0
 public MonetaryValue(
     Iso4217CurrencyCode currency,
     int amount,
     int exponent)
 {
     this.currency = currency;
     this.amount   = new DerInteger(amount);
     this.exponent = new DerInteger(exponent);
 }
コード例 #2
0
		public MonetaryValue(
            Iso4217CurrencyCode	currency,
            int					amount,
            int					exponent)
        {
            this.currency = currency;
            this.amount = new DerInteger(amount);
            this.exponent = new DerInteger(exponent);
        }
コード例 #3
0
		private MonetaryValue(
            Asn1Sequence seq)
        {
			if (seq.Count != 3)
				throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");

            currency = Iso4217CurrencyCode.GetInstance(seq[0]);
            amount = DerInteger.GetInstance(seq[1]);
            exponent = DerInteger.GetInstance(seq[2]);
        }
コード例 #4
0
 private MonetaryValue(Asn1Sequence seq)
 {
     if (seq.Count != 3)
     {
         throw new ArgumentException("Bad sequence size: " + seq.Count, "seq");
     }
     this.currency = Iso4217CurrencyCode.GetInstance(seq[0]);
     this.amount   = DerInteger.GetInstance(seq[1]);
     this.exponent = DerInteger.GetInstance(seq[2]);
 }
コード例 #5
0
 private MonetaryValue(Asn1Sequence seq)
 {
     //IL_0029: Unknown result type (might be due to invalid IL or missing references)
     if (seq.Count != 3)
     {
         throw new ArgumentException(string.Concat((object)"Bad sequence size: ", (object)seq.Count), "seq");
     }
     currency = Iso4217CurrencyCode.GetInstance(seq[0]);
     amount   = DerInteger.GetInstance(seq[1]);
     exponent = DerInteger.GetInstance(seq[2]);
 }
コード例 #6
0
		public override void PerformTest()
        {
            //
            // alphabetic
            //
            Iso4217CurrencyCode cc = new Iso4217CurrencyCode(AlphabeticCurrencyCode);

            CheckNumeric(cc, AlphabeticCurrencyCode);

            cc = Iso4217CurrencyCode.GetInstance(cc);

            CheckNumeric(cc, AlphabeticCurrencyCode);

            Asn1Object obj = cc.ToAsn1Object();

            cc = Iso4217CurrencyCode.GetInstance(obj);

            CheckNumeric(cc, AlphabeticCurrencyCode);

            //
            // numeric
            //
            cc = new Iso4217CurrencyCode(NUMERIC_CurrencyCode);

            CheckNumeric(cc, NUMERIC_CurrencyCode);

            cc = Iso4217CurrencyCode.GetInstance(cc);

            CheckNumeric(cc, NUMERIC_CurrencyCode);

            obj = cc.ToAsn1Object();

            cc = Iso4217CurrencyCode.GetInstance(obj);

            CheckNumeric(cc, NUMERIC_CurrencyCode);

            cc = Iso4217CurrencyCode.GetInstance(null);

            if (cc != null)
            {
                Fail("null GetInstance() failed.");
            }

            try
            {
                Iso4217CurrencyCode.GetInstance(new object());

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }

            try
            {
                new Iso4217CurrencyCode("ABCD");

                Fail("constructor failed to detect out of range currencycode.");
            }
            catch (ArgumentException)
            {
                // expected
            }

            try
            {
                new Iso4217CurrencyCode(0);

                Fail("constructor failed to detect out of range small numeric code.");
            }
            catch (ArgumentException)
            {
                // expected
            }

            try
            {
                new Iso4217CurrencyCode(1000);

                Fail("constructor failed to detect out of range large numeric code.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
コード例 #7
0
        private void CheckNumeric(
            Iso4217CurrencyCode cc,
            int                 code)
        {
            if (cc.IsAlphabetic)
            {
                Fail("alphabetic code found when one not expected.");
            }

            if (cc.Numeric != code)
            {
                Fail("numeric codes don't match.");
            }
        }
コード例 #8
0
        private void CheckNumeric(
            Iso4217CurrencyCode cc,
            string              code)
        {
            if (!cc.IsAlphabetic)
            {
                Fail("non-alphabetic code found when one expected.");
            }

            if (!cc.Alphabetic.Equals(code))
            {
                Fail("string codes don't match.");
            }
        }