Class UrlBuilder
An extension of the UriBuilder which is specifically tailored for convenience and expressive code during URL creation. It additionally implements IBuilder, thus enabling the default set of builder extension methods on this class.
Implements
Namespace: ReqRest.Builders
Assembly: ReqRest.dll
Syntax
public class UrlBuilder : UriBuilder, IBuilder
Constructors
UrlBuilder(Nullable<String>, Nullable<String>, Nullable<Int32>, Nullable<String>, Nullable<String>)
Initializes a new UrlBuilder instance which starts building on an URL built from the specified values.
Declaration
public UrlBuilder(string? scheme = default(string? ), string? host = default(string? ), int? port, string? path = default(string? ), string? extraValue = default(string? ))
Parameters
Type | Name | Description |
---|---|---|
Nullable<String> | scheme | The URL's scheme. |
Nullable<String> | host | The URL's host. |
Nullable<Int32> | port | The URL's port. |
Nullable<String> | path | The URL's path. |
Nullable<String> | extraValue | The URL's extra value. |
UrlBuilder(String)
Initializes a new UrlBuilder instance which starts building
on the specified uri
.
Declaration
public UrlBuilder(string uri)
Parameters
Type | Name | Description |
---|---|---|
String | uri | A string representing a URL. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
UrlBuilder(Uri)
Initializes a new UrlBuilder instance which starts building
on the specified uri
.
Declaration
public UrlBuilder(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | An Uri representing a URL. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Operators
BitwiseAnd(UrlBuilder, KeyValuePair<Nullable<String>, Nullable<String>>)
Formats the specified parameter consisting of a key and value into
a query parameters (similar to &key=value
) and appends it at the
end of the Query string.
If the query ends with or if the final parameter starts with one or
more "&"
characters, they are trimmed, so that there is only a single
"&"
between the old query and the new parameter.
Declaration
public static UrlBuilder operator &(UrlBuilder builder, KeyValuePair<string? , string? > queryParameter)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | builder | The builder. |
KeyValuePair<Nullable<String>, Nullable<String>> | queryParameter | A query parameter consisting of a key and value which should be appended to the query. |
Returns
Type | Description |
---|---|
UrlBuilder | The specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
BitwiseAnd(UrlBuilder, Nullable<String>)
Appends the specified queryParameter
at the end of the
Query.
If the query ends with or if the queryParameter
starts with one or
more "&"
characters, they are trimmed, so that there is only a single
"&"
between the old query and the new parameter.
Declaration
public static UrlBuilder operator &(UrlBuilder builder, string? queryParameter)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | builder | The builder. |
Nullable<String> | queryParameter | The query parameter to be appended to the query. This can be null. If so (or if empty), nothing gets appended. |
Returns
Type | Description |
---|---|
UrlBuilder | The specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
BitwiseAnd(UrlBuilder, (Nullable<String> Key, Nullable<String> Value))
Formats the specified parameter consisting of a key and value into
a query parameters (similar to &key=value
) and appends it at the
end of the Query string.
If the query ends with or if the final parameter starts with one or
more "&"
characters, they are trimmed, so that there is only a single
"&"
between the old query and the new parameter.
Declaration
public static UrlBuilder operator &(UrlBuilder builder, (string? Key, string? Value)queryParameter)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | builder | The builder. |
ValueTuple<Nullable<String>, Nullable<String>> | queryParameter | A query parameter consisting of a key and value which should be appended to the query. |
Returns
Type | Description |
---|---|
UrlBuilder | The specified |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Division(UrlBuilder, Nullable<String>)
Appends the specified pathSegment
to the builder's
Path and returns the same builder instance.
If the existing path ends with a single slash, or if the pathSegment
starts with a single slash, the slashes are stripped, so that the resulting path
only has a single slash between the two concatenated parts.
If the existing path starts with multiple slashes, or if the pathSegment
starts with multiple slashes, they are kept and appended to each other.
Declaration
public static UrlBuilder operator /(UrlBuilder builder, string? pathSegment)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | builder | The builder. |
Nullable<String> | pathSegment | The segment to be appended to the builder's path. This can be null. |
Returns
Type | Description |
---|---|
UrlBuilder | The specified |
Implicit(UrlBuilder to Nullable<Uri>)
Declaration
public static implicit operator Uri? (UrlBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | builder | The builder. |
Returns
Type | Description |
---|---|
Nullable<Uri> | The Uri built by the builder or null if
|
Exceptions
Type | Condition |
---|---|
UriFormatException | The URI constructed by the UriBuilder properties is invalid. |