diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index f9eddd5..f8ee5b9 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -110,7 +110,7 @@ - + diff --git a/ICD.Common.Utils/UriUtils.cs b/ICD.Common.Utils/UriUtils.cs index aec717d..e9b7705 100644 --- a/ICD.Common.Utils/UriUtils.cs +++ b/ICD.Common.Utils/UriUtils.cs @@ -1,9 +1,17 @@ using System; +using System.Collections.Generic; namespace ICD.Common.Utils { public static class UriUtils { + private static readonly Dictionary s_SchemeToPort = + new Dictionary(StringComparer.OrdinalIgnoreCase) + { + {Uri.UriSchemeHttp, 80}, + {Uri.UriSchemeHttps, 443} + }; + /// /// Attempts to parse the given URI string into a System.Uri instance. /// @@ -27,5 +35,16 @@ namespace ICD.Common.Utils return false; } } + + /// + /// Gets the port number for the given URI scheme. + /// + /// + /// + /// + public static bool TryGetPortForScheme(string scheme, out ushort port) + { + return s_SchemeToPort.TryGetValue(scheme, out port); + } } }