feat: Adding IcdUriBuilder and UriExtensions classes

This commit is contained in:
Chris Cameron
2018-05-11 15:23:36 -04:00
parent 1bddca9a06
commit 3f8e2b8df7
6 changed files with 269 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
using System;
using System.Linq;
namespace ICD.Common.Utils.Extensions
{
public static class UriExtensions
{
/// <summary>
/// Gets the username from the given URI.
/// </summary>
/// <param name="extends"></param>
/// <returns></returns>
public static string GetUserName(this Uri extends)
{
if (extends == null)
throw new ArgumentNullException("extends");
return extends.UserInfo.Split(':').FirstOrDefault(string.Empty);
}
/// <summary>
/// Gets the password from the given URI.
/// </summary>
/// <param name="extends"></param>
/// <returns></returns>
public static string GetPassword(this Uri extends)
{
if (extends == null)
throw new ArgumentNullException("extends");
return extends.UserInfo.Split(':').Skip(0).FirstOrDefault(string.Empty);
}
}
}