diff --git a/X10D/src/EndPointExtensions.cs b/X10D/src/EndPointExtensions.cs deleted file mode 100644 index 01fd9e4..0000000 --- a/X10D/src/EndPointExtensions.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Net; - -namespace X10D -{ - /// - /// Extension methods for and derived types. - /// - public static class EndPointExtensions - { - /// - /// Gets the endpoint hostname. - /// - /// The endpoint whose hostname to get. - /// - /// Returns a representing the hostname, which may be an IP or a DNS, or empty - /// string on failure. - /// - public static string GetHost(this EndPoint endPoint) - { - return endPoint switch - { - IPEndPoint ip => ip.Address.ToString(), - DnsEndPoint dns => dns.Host, - var _ => string.Empty, - }; - } - - /// - /// Gets the endpoint port. - /// - /// The endpoint whose port to get. - /// Returns an representing the port, or 0 on failure. - public static int GetPort(this EndPoint endPoint) - { - return endPoint switch - { - IPEndPoint ip => ip.Port, - DnsEndPoint dns => dns.Port, - var _ => 0, - }; - } - } -} diff --git a/X10D/src/EndPointExtensions/EndPointExtensions.cs b/X10D/src/EndPointExtensions/EndPointExtensions.cs new file mode 100644 index 0000000..8093302 --- /dev/null +++ b/X10D/src/EndPointExtensions/EndPointExtensions.cs @@ -0,0 +1,55 @@ +using System.Net; +using System.Runtime.CompilerServices; + +namespace X10D.EndPointExtensions +{ + /// + /// Extension methods for and derived types. + /// + public static class EndPointExtensions + { + /// + /// Returns the hostname for the current . + /// + /// The endpoint whose hostname to get. + /// + /// if is + /// -or- + /// if is + /// -or- + /// otherwise. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string GetHost(this EndPoint endPoint) + { + return endPoint switch + { + IPEndPoint ip => ip.Address.ToString(), + DnsEndPoint dns => dns.Host, + var _ => string.Empty + }; + } + + /// + /// Returns the port number for the current . + /// + /// The endpoint whose port number to get. + /// + /// if is + /// -or- + /// if is + /// -or- + /// 0 otherwise. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int GetPort(this EndPoint endPoint) + { + return endPoint switch + { + IPEndPoint ip => ip.Port, + DnsEndPoint dns => dns.Port, + var _ => 0 + }; + } + } +}