Class PhoneNumberToCarrierMapper
- Namespace
- PhoneNumbers
- Assembly
- PhoneNumbers.dll
A phone prefix mapper which provides carrier information related to a phone number.
Carrier data is the one the number was originally allocated to. If the country supports mobile number portability the number might not belong to the returned carrier anymore.
public sealed class PhoneNumberToCarrierMapper
- Inheritance
-
PhoneNumberToCarrierMapper
- Inherited Members
Methods
GetInstance()
Gets the singleton PhoneNumberToCarrierMapper instance.
public static PhoneNumberToCarrierMapper GetInstance()
Returns
GetNameForNumber(PhoneNumber, Locale)
Gets the name of the carrier for the given phone number, in the language provided. As per GetNameForValidNumber(PhoneNumber, Locale) but explicitly checks the validity of the number passed in, and returns empty string if the number is not a mobile or pager number.
public string GetNameForNumber(PhoneNumber number, Locale languageCode)
Parameters
numberPhoneNumberThe phone number for which we want to get a carrier name.
languageCodeLocaleThe language code in which the name should be written.
Returns
- string
A carrier name for the given phone number, or empty string if the number passed in is invalid or is not a mobile/pager number.
GetNameForValidNumber(PhoneNumber, Locale)
Returns a carrier name for the given phone number, in the language provided.
The carrier name is the one the number was originally allocated to. If the country supports mobile number portability the number might not belong to the returned carrier anymore. If no mapping is found an empty string is returned.
This method assumes the validity of the number passed in has already been checked, and that the number is suitable for carrier lookup. We consider mobile and pager numbers possible candidates for carrier lookup.
public string GetNameForValidNumber(PhoneNumber number, Locale languageCode)
Parameters
numberPhoneNumberA valid phone number for which we want to get a carrier name.
languageCodeLocaleThe language code in which the name should be written.
Returns
- string
A carrier name for the given phone number, or empty string if not found.
GetSafeDisplayName(PhoneNumber, Locale)
Gets the name of the carrier for the given phone number only when it is 'safe' to display to users. A carrier name is considered safe if the number is valid and for a region that doesn't support mobile number portability.
public string GetSafeDisplayName(PhoneNumber number, Locale languageCode)
Parameters
numberPhoneNumberThe phone number for which we want to get a carrier name.
languageCodeLocaleThe language code in which the name should be written.
Returns
- string
A carrier name that is safe to display to users, or the empty string.