예제 #1
0
        private static bool TryParseIPNetwork(string ip, CidrParseEnum cidrParseEnum, byte cidr, out IPNetwork ipn)
        {
            IPNetwork ipnetwork = null;

            if (cidrParseEnum == CidrParseEnum.Default)
            {
                if (!IPNetwork.TryParse(ip, out ipnetwork))
                {
                    ipn = null;
                    return(false);
                }
            }
            else if (cidrParseEnum == CidrParseEnum.Value)
            {
                if (!IPNetwork.TryParse(ip, cidr, out ipnetwork))
                {
                    if (!IPNetwork.TryParse(ip, out ipnetwork))
                    {
                        ipn = null;
                        return(false);
                    }
                }
            }
            ipn = ipnetwork;
            return(true);
        }
예제 #2
0
        private static bool TryParseIPNetwork(string ip, CidrParseEnum cidrParseEnum, byte cidr, out IPNetwork ipn) {

            IPNetwork ipnetwork = null;
            if (cidrParseEnum == CidrParseEnum.Default) {
                if (!IPNetwork.TryParse(ip, out ipnetwork)) {
                    ipn = null;
                    return false;
                }
            }
            else if (cidrParseEnum == CidrParseEnum.Value) {
                if (!IPNetwork.TryParse(ip, cidr, out ipnetwork)) {
                    if (!IPNetwork.TryParse(ip, out ipnetwork)) {
                        ipn = null;
                        return false;
                    }
                }
            }
            ipn = ipnetwork;
            return true;
        }