Exemplo n.º 1
0
        public static Outcome <Bic> TryParse(string value, BicVersion version)
        {
            if (value == null || !CheckLength(value))
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidBicValue, value)));
            }

            string institutionCode = InstitutionPart.FromBic(value, version);

            if (institutionCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_InstitutionCode, value)));
            }

            string countryCode = CountryPart.FromBic(value);

            if (countryCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_CountryCode, value)));
            }

            string locationCode = LocationPart.FromBic(value);

            if (locationCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_LocationCode, value)));
            }

            string branchCode = BranchPart.FromBic(value);

            if (branchCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_BranchCode, value)));
            }

            return(Outcome.Of(new Bic(institutionCode, countryCode, locationCode, branchCode, value)));
        }
Exemplo n.º 2
0
        public static Bic?Parse(string value, BicVersion version)
        {
            if (value == null || !CheckLength(value))
            {
                return(null);
            }

            string institutionCode = InstitutionPart.FromBic(value, version);

            if (institutionCode == null)
            {
                return(null);
            }

            string countryCode = CountryPart.FromBic(value);

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

            string locationCode = LocationPart.FromBic(value);

            if (locationCode == null)
            {
                return(null);
            }

            string branchCode = BranchPart.FromBic(value);

            if (branchCode == null)
            {
                return(null);
            }

            return(new Bic(institutionCode, countryCode, locationCode, branchCode, value));
        }