Пример #1
0
        private IbanCountry?GetMatchingCountry(string iban)
        {
            string?countryCode = GetCountryCode(iban);

            if (countryCode is null)
            {
                return(null);
            }

            return(_ibanRegistry.TryGetValue(countryCode, out IbanCountry? country) ? country : null);
        }
Пример #2
0
        /// <summary>
        /// Adds the specified <paramref name="countryCode"/> to the builder.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="countryCode">The country code.</param>
        /// <param name="registry">The IBAN registry to resolve the country from.</param>
        /// <returns>The builder to continue chaining.</returns>
        public static IBankAccountBuilder WithCountry(this IBankAccountBuilder builder, string countryCode, IIbanRegistry registry)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (registry is null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (!registry.TryGetValue(countryCode, out IbanCountry? country))
            {
                throw new ArgumentException(Resources.ArgumentException_Builder_The_country_code_is_not_registered, nameof(countryCode));
            }

            return(builder.WithCountry(country));
        }