コード例 #1
0
 private static bool AreEqual(PhoneNumber.Builder p1, PhoneNumber.Builder p2)
 {
     return p1.Clone().Build().Equals(p2.Clone().Build());
 }
コード例 #2
0
 /**
 * Attempts to extract a valid number from a phone number that is too long to be valid, and resets
 * the PhoneNumber object passed in to that valid version. If no valid number could be extracted,
 * the PhoneNumber object passed in will not be modified.
 * @param number a PhoneNumber object which contains a number that is too long to be valid.
 * @return  true if a valid phone number can be successfully extracted.
 */
 public bool TruncateTooLongNumber(PhoneNumber.Builder number)
 {
     if (IsValidNumber(number.Clone().Build()))
         return true;
     PhoneNumber copy = null;
     ulong nationalNumber = number.NationalNumber;
     do
     {
         nationalNumber /= 10;
         PhoneNumber.Builder numberCopy = number.Clone();
         numberCopy.SetNationalNumber(nationalNumber);
         copy = numberCopy.Build();
         if (IsPossibleNumberWithReason(copy) == ValidationResult.TOO_SHORT ||
           nationalNumber == 0)
             return false;
     }
     while (!IsValidNumber(copy));
     number.SetNationalNumber(nationalNumber);
     return true;
 }