public void RegisterRegions(Country country, IExceptionalCountryCode exceptionalCountry) { //if (_exceptionalCountries.ContainsKey(country)) // _exceptionalCountries[country].Add(exceptionalCountry); //else _exceptionalCountries.Add(country, new List<IExceptionalCountryCode> {exceptionalCountry}); _exceptionalCountries.Add(country, exceptionalCountry); }
private static bool MatchCombination(string phoneNumber, IExceptionalCountryCode definition) { return(definition.InternationalPrefixes.Any(internationalPrefix => definition.CountryCodes.Any(countryCode => phoneNumber.StartsWith(internationalPrefix + countryCode) ) )); }
/// <summary> /// Find countries that do not follows the ITU-T recommendations /// </summary> /// <param name="selectedException"></param> /// <param name="phoneNumber"></param> /// <returns></returns> private static bool IsExceptionalPhoneNumber(out IExceptionalCountryCode selectedException, string phoneNumber) { foreach (var definition in ExceptionalContainer.GetAllDefinitions()) { if (definition.CustomValidation != null && definition.CustomValidation(phoneNumber)) { selectedException = definition; return(true); } if (MatchCombination(phoneNumber, definition)) { selectedException = definition; return(true); } } selectedException = null; return(false); }