init
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FluentUriBuilder
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
public Class1()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/FluentUriBuilder/TerribleDevUriExtensions.cs
Normal file
33
src/FluentUriBuilder/TerribleDevUriExtensions.cs
Normal file
@@ -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<object> 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(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user