Extension for the .net UriBuilder to simply extend the query
- Add the nuget Package to your Project
- Add Using eg.
using UriBuilderExtension
;
To add a query parameter use the method `SetQueryParam``
UriBuilder uriBuilder = new UriBuilder();
uriBuilder.Scheme = "https";
uriBuilder.Host = "www.google.com";
uriBuilder.Path = "search";
// The magic happens here
uriBuilder.SetQueryParam("q", "query+goes+here");
// or
uriBuilder.SetQueryParam("p", new String[] {"here" ,"and+here"});
If you want to check is a parameter exsit in the query use
bool exsists = uriBuilder.HasQueryParam("p")
To get the value/values of a parameter use
var value = uriBuilder.GetQueryParamValue("p")
To get all parameter keys of the query use
var value = uriBuilder.GetQueryParamKeys();
To Remove one parameter use
uriBuilder.RemoveQueryParam("q");