コード例 #1
0
 public MeumProxyAddressE164(string address, bool primaryAddress) : base(address, primaryAddress)
 {
     if (!MeumProxyAddressE164.ValidateAddress(address))
     {
         throw new ArgumentOutOfRangeException(DataStrings.ExceptionInvalidMeumAddress(address ?? "<null>"), null);
     }
 }
コード例 #2
0
        internal static bool ValidateAddress(string address)
        {
            if (string.IsNullOrEmpty(address))
            {
                return(false);
            }
            SmtpAddress smtpAddress = new SmtpAddress(address);

            return(smtpAddress.IsValidAddress && MeumProxyAddressE164.IsNumber(smtpAddress.Local) && string.Equals(smtpAddress.Domain, "um.exchangelabs.com", StringComparison.OrdinalIgnoreCase));
        }
コード例 #3
0
 public static MeumProxyAddress CreateFromAddressString(string address, bool primaryAddress)
 {
     if (MeumProxyAddressE164.ValidateAddress(address))
     {
         return(new MeumProxyAddressE164(address, primaryAddress));
     }
     if (MeumProxyAddressGateway.ValidateAddress(address))
     {
         return(new MeumProxyAddressGateway(address, primaryAddress));
     }
     throw new ArgumentOutOfRangeException(DataStrings.ExceptionInvalidMeumAddress(address ?? "<null>"), null);
 }
コード例 #4
0
        internal static MeumProxyAddressE164 CreateFromE164(string phoneNumber, bool primaryAddress)
        {
            if (!MeumProxyAddressE164.ValidateE164Number(phoneNumber))
            {
                throw new ArgumentOutOfRangeException("phoneNumber", phoneNumber, "Invalid E164 number");
            }
            SmtpAddress smtpAddress = new SmtpAddress(phoneNumber.Substring(1), "um.exchangelabs.com");

            if (!smtpAddress.IsValidAddress)
            {
                throw new ArgumentOutOfRangeException("phoneNumber", phoneNumber, string.Format("Invalid SMTP address - {0}", smtpAddress.ToString()));
            }
            return(new MeumProxyAddressE164(smtpAddress.ToString(), primaryAddress));
        }
コード例 #5
0
 public static MeumProxyAddress CreateFromE164(string phoneNumber, bool primaryAddress)
 {
     return(MeumProxyAddressE164.CreateFromE164(phoneNumber, primaryAddress));
 }
コード例 #6
0
 internal static bool ValidateE164Number(string phoneNumber)
 {
     return(!string.IsNullOrEmpty(phoneNumber) && phoneNumber[0] == '+' && phoneNumber.Length > 1 && MeumProxyAddressE164.IsNumber(phoneNumber.Substring(1)));
 }