mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feat: Initial commit of UriUtils
This commit is contained in:
parent
f76f4773e5
commit
8da73593c4
2 changed files with 32 additions and 0 deletions
|
|
@ -178,6 +178,7 @@
|
|||
<Compile Include="Timers\Repeater.cs" />
|
||||
<Compile Include="Timers\SafeTimer.cs" />
|
||||
<Compile Include="TryUtils.cs" />
|
||||
<Compile Include="UriUtils.cs" />
|
||||
<Compile Include="Xml\IcdXmlConvert.cs" />
|
||||
<Compile Include="Xml\IcdXmlDocument.cs" />
|
||||
<Compile Include="Xml\IcdXmlException.cs" />
|
||||
|
|
|
|||
31
ICD.Common.Utils/UriUtils.cs
Normal file
31
ICD.Common.Utils/UriUtils.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace ICD.Common.Utils
|
||||
{
|
||||
public static class UriUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to parse the given URI string into a System.Uri instance.
|
||||
/// </summary>
|
||||
/// <param name="uri"></param>
|
||||
/// <param name="output"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryParse(string uri, out Uri output)
|
||||
{
|
||||
output = null;
|
||||
|
||||
if (string.IsNullOrEmpty(uri))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
output = new Uri(uri);
|
||||
return true;
|
||||
}
|
||||
catch (UriFormatException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue