mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-13 03:35:04 +00:00
feat: Initial commit of UriUtils
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user