System.Net.EndpointPermission.CheckEndPointName C# (CSharp) Method

CheckEndPointName() private static method

private static CheckEndPointName ( string name ) : EndPointType
name string
return EndPointType
    private static EndPointType CheckEndPointName(string name) {
        if (name == null) {
            return EndPointType.Invalid;
        }
        bool isIPv6       = false;
        bool isDnsOrWC    = false;
        bool isHexLetter  = false;
        for(int i=0; i < name.Length; ++i) {
            char ch = name[i];
            switch(ch) {
            case '.':   //note _all_ dots name is an error
                        continue;
            case '-':   //if _all_ chars are those we call Dns (to confirm error)
            case '_':
            case '*':   isDnsOrWC = true;
                        continue;
            case ':':
            case '%':   isIPv6 = true;
                        continue;
            default:    break;
            }

            //Check on letters but NOT hex digits
            if ((ch > 'f' && ch <= 'z') || (ch > 'F' && ch <= 'Z')) {
                isDnsOrWC = true;
                continue;
            }
            //Check on HEX letters
            if((ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')) {
                isHexLetter = true;
                continue;
            }
            //Here only digits left (others are invalid)
            if (!(ch >= '0' && ch <= '9'))
                return EndPointType.Invalid;
        }

        // The logic is (solely for the purpose of SocketPermssion class)
        //  isIPv6 && isDnsOrWC   = EndPointType.Invalid
        //  isIPv6 && !isDnsOrWC  = EndPointType.IPv6
        //  !isIPv6 && isDnsOrWC  = EndPointType.DnsOrWildcard
        //  !isIPv6 && !isDnsOrWC && isHexLetter = EndPointType.DnsOrWildcard;
        //  else = EndPointType.IPv4
        return isIPv6 ? (isDnsOrWC? EndPointType.Invalid: EndPointType.IPv6)
                      : (isDnsOrWC? EndPointType.DnsOrWildcard :
                                    isHexLetter? EndPointType.DnsOrWildcard :EndPointType.IPv4);
    }