From 8da73593c441af7f17412abd152c1edbd9a8558a Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 15 May 2018 13:29:24 -0400 Subject: [PATCH] feat: Initial commit of UriUtils --- .../ICD.Common.Utils_SimplSharp.csproj | 1 + ICD.Common.Utils/UriUtils.cs | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 ICD.Common.Utils/UriUtils.cs diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index 957c471..89b8d8a 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -178,6 +178,7 @@ + diff --git a/ICD.Common.Utils/UriUtils.cs b/ICD.Common.Utils/UriUtils.cs new file mode 100644 index 0000000..aec717d --- /dev/null +++ b/ICD.Common.Utils/UriUtils.cs @@ -0,0 +1,31 @@ +using System; + +namespace ICD.Common.Utils +{ + public static class UriUtils + { + /// + /// Attempts to parse the given URI string into a System.Uri instance. + /// + /// + /// + /// + 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; + } + } + } +}