diff --git a/src/FluentUriBuilder/Class1.cs b/src/FluentUriBuilder/Class1.cs deleted file mode 100644 index f3d076a..0000000 --- a/src/FluentUriBuilder/Class1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace FluentUriBuilder -{ - public class Class1 - { - public Class1() - { - } - } -} diff --git a/src/FluentUriBuilder/TerribleDevUriExtensions.cs b/src/FluentUriBuilder/TerribleDevUriExtensions.cs new file mode 100644 index 0000000..4391ac8 --- /dev/null +++ b/src/FluentUriBuilder/TerribleDevUriExtensions.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace System +{ + public static class TerribleDevUriExtensions + { + public static void WithParameter(this UriBuilder bld, string key, string value) + { + if(!string.IsNullOrWhiteSpace(bld.Query)) + { + bld.Query += $"&{key}={value}"; + return; + } + bld.Query = $"{key}={value}"; + } + + public static void WithParameter(this UriBuilder bld, string key, IEnumerable values) + { + var isfirst = string.IsNullOrWhiteSpace(bld.Query); + var intitialValue = isfirst ? "?" : "&"; + var sb = new StringBuilder($"{intitialValue}{key}="); + foreach(var value in values) + { + sb.Append($"{value.ToString()},"); + } + bld.Query = sb.ToString().TrimEnd(','); + } + } +} \ No newline at end of file