Exemplo n.º 1
0
        /// <inheritdoc />
        public string Build()
        {
            string countryCode;
            string bban;

            char[] buffer;

            try
            {
                bban = _bbanBuilder.Build();

                countryCode = _country.TwoLetterISORegionName;
                buffer      = new char[_country.Iban.Length];

                // Compute check digit.
                CopyToBuffer(buffer,
                             countryCode,
                             0,
                             bban,
                             countryCodePos: bban.Length,
                             checkDigitPos: bban.Length + countryCode.Length,
                             bbanPos: 0);
            }
            catch (BankAccountBuilderException ex)
            {
                throw new BankAccountBuilderException(Resources.Exception_Builder_The_IBAN_cannot_be_built, ex.InnerException);
            }

            // Return IBAN.
            int checkDigits = InverseMod97PlusExpectedCheckDigit - _checkDigitCalculator.Compute(buffer);

            CopyToBuffer(buffer, countryCode, checkDigits, bban);

            return(new string(buffer));
        }
        /// <inheritdoc />
        public int Compute(char[] value)
        {
            var mod97 = _innerCalculator.Compute(value);

            return(mod97 == 0
                ? 97
                : mod97);
        }
Exemplo n.º 3
0
 /// <inheritdoc />
 public int Compute(char[] value)
 {
     return(98 - _innerCalculator.Compute(value));
 }