SIPSorcery.Net.DNSManager.MatchIPAddress C# (CSharp) Méthode

MatchIPAddress() private static méthode

private static MatchIPAddress ( string hostname ) : Heijden.DNS.DNSResponse
hostname string
Résultat Heijden.DNS.DNSResponse
        private static DNSResponse MatchIPAddress(string hostname)
        {
            try
            {
                if (hostname != null && hostname.Trim().Length > 0)
                {
                    hostname = hostname.Trim();

                    if (Regex.Match(hostname, @"(\d+\.){3}\d+(:\d+$|$)").Success)
                    {
                        string ipAddress = Regex.Match(hostname, @"(?<ipaddress>(\d+\.){3}\d+)(:\d+$|$)").Result("${ipaddress}");
                        DNSResponse result = new DNSResponse(IPAddress.Parse(ipAddress));
                        return result;
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    return null;
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception DNSManager MatchIPAddress. " + excp);
                return null;
            }
        }