diff --git a/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs b/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs index ac3f8ea..32d88dd 100644 --- a/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs +++ b/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs @@ -8,8 +8,22 @@ namespace System { public static class TerribleDevUriExtensions { + /// + /// Appends a query string parameter with a key, and many values. Multiple values will be comma seperated. If only 1 value is passed and its null or value, the key will be added to the QS. + /// + /// + /// + /// + /// public static UriBuilder WithParameter(this UriBuilder bld, string key, params string[] values) => bld.WithParameter(key, valuesEnum: values); + /// + /// Appends a query string parameter with a key, and many values. Multiple values will be comma seperated. If only 1 value is passed and its null or value, the key will be added to the QS. + /// + /// + /// + /// + /// public static UriBuilder WithParameter(this UriBuilder bld, string key, IEnumerable valuesEnum) { if(string.IsNullOrWhiteSpace(key)) @@ -20,8 +34,7 @@ namespace System { valuesEnum = new string[0]; } - var isfirst = string.IsNullOrWhiteSpace(bld.Query); - var intitialValue = isfirst ? "" : $"{bld.Query.TrimStart('?')}&"; + var intitialValue = string.IsNullOrWhiteSpace(bld.Query) ? "" : $"{bld.Query.TrimStart('?')}&"; var sb = new StringBuilder($"{intitialValue}{key}"); var validValueHit = false; foreach(var value in valuesEnum) @@ -37,6 +50,13 @@ namespace System return bld; } + /// + /// Sets the port to be the port number + /// + /// + /// + /// Throws if port is less than one + /// public static UriBuilder WithPort(this UriBuilder bld, int port) { if(port < 1) throw new ArgumentOutOfRangeException(nameof(port)); @@ -44,6 +64,13 @@ namespace System return bld; } + /// + /// appends a path segment to the path. Can be called multiple times to append multiple segments + /// + /// + /// + /// You pass a string as a path segment + /// public static UriBuilder WithPathSegment(this UriBuilder bld, string pathSegment) { if(string.IsNullOrWhiteSpace(pathSegment)) @@ -55,6 +82,13 @@ namespace System return bld; } + /// + /// Sets your Uri Scheme + /// + /// + /// + /// You must pass a scheme + /// public static UriBuilder WithScheme(this UriBuilder bld, string scheme) { if(string.IsNullOrWhiteSpace(scheme)) throw new ArgumentNullException(nameof(scheme)); @@ -62,6 +96,13 @@ namespace System return bld; } + /// + /// + /// + /// + /// + /// You must pass a ho0st + /// public static UriBuilder WithHost(this UriBuilder bld, string host) { if(string.IsNullOrWhiteSpace(host)) throw new ArgumentNullException(nameof(host)); @@ -69,6 +110,12 @@ namespace System return bld; } + /// + /// Use Https? + /// + /// + /// default true, if false sets scheme to http + /// public static UriBuilder UseHttps(this UriBuilder bld, bool predicate = true) { bld.Scheme = predicate ? "https" : "http";