mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 21:24:58 +00:00
feat: Adding TryGetPortForScheme method to UriExtensions
This commit is contained in:
@@ -110,7 +110,7 @@
|
|||||||
<Compile Include="Extensions\MethodInfoExtensions.cs" />
|
<Compile Include="Extensions\MethodInfoExtensions.cs" />
|
||||||
<Compile Include="Extensions\ParameterInfoExtensions.cs" />
|
<Compile Include="Extensions\ParameterInfoExtensions.cs" />
|
||||||
<Compile Include="Extensions\UriExtensions.cs" />
|
<Compile Include="Extensions\UriExtensions.cs" />
|
||||||
<Compile Include="Extensions\UshortExtensions.cs" />
|
<Compile Include="Extensions\UShortExtensions.cs" />
|
||||||
<Compile Include="IcdUriBuilder.cs" />
|
<Compile Include="IcdUriBuilder.cs" />
|
||||||
<Compile Include="IO\Compression\IcdZipEntry.cs" />
|
<Compile Include="IO\Compression\IcdZipEntry.cs" />
|
||||||
<Compile Include="IO\IcdBinaryReader.cs" />
|
<Compile Include="IO\IcdBinaryReader.cs" />
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ICD.Common.Utils
|
namespace ICD.Common.Utils
|
||||||
{
|
{
|
||||||
public static class UriUtils
|
public static class UriUtils
|
||||||
{
|
{
|
||||||
|
private static readonly Dictionary<string, ushort> s_SchemeToPort =
|
||||||
|
new Dictionary<string, ushort>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
{Uri.UriSchemeHttp, 80},
|
||||||
|
{Uri.UriSchemeHttps, 443}
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to parse the given URI string into a System.Uri instance.
|
/// Attempts to parse the given URI string into a System.Uri instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -27,5 +35,16 @@ namespace ICD.Common.Utils
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the port number for the given URI scheme.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="scheme"></param>
|
||||||
|
/// <param name="port"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool TryGetPortForScheme(string scheme, out ushort port)
|
||||||
|
{
|
||||||
|
return s_SchemeToPort.TryGetValue(scheme, out port);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user