Esempio n. 1
0
        public static bool TryParse(String candidate, bool allowPartialIP, bool allowName, out ComparableAddress address)
        {
            address = null;
            if (string.IsNullOrEmpty(candidate))
            {
                return(false);
            }

            IPAddress ipAddress;
            PartialIP pip;

            if (IPAddress.TryParse(candidate, out ipAddress))
            {
                address = new ComparableAddress(ipAddress.GetAddressBytes());
                return(true);
            }

            else if (allowPartialIP && PartialIP.TryParse(candidate, out pip))
            {
                address = new ComparableAddress(pip);
                return(true);
            }

            else if (allowName)
            {
                address = new ComparableAddress(candidate);
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public static bool TryParse(String candidate, out PartialIP ip)
        {
            ip = null;

            if (!CouldBeValidPartialIp(candidate))
                return false;

            try
            {
                ip = Parse(candidate);
                return true;
            }
            catch
            {
                return false;
            }
        }
Esempio n. 3
0
        public static bool TryParse(String candidate, out PartialIP ip)
        {
            ip = null;

            if (!CouldBeValidPartialIp(candidate))
            {
                return(false);
            }

            try
            {
                ip = Parse(candidate);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 4
0
 private ComparableAddress(PartialIP pip)
 {
     partialIP = pip;
 }
Esempio n. 5
0
 private ComparableAddress(PartialIP pip)
 {
     partialIP = pip;
 }