feat: Initial commit of UriUtils

This commit is contained in:
Chris Cameron
2018-05-15 13:29:24 -04:00
parent f76f4773e5
commit 8da73593c4
2 changed files with 32 additions and 0 deletions

View File

@@ -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" />

View 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;
}
}
}
}