Class UriBuilderExtensions
Extends the UriBuilder class with fluent extension methods.
Namespace: ReqRest.Builders
Assembly: ReqRest.dll
Syntax
public static class UriBuilderExtensions
Methods
AppendPath<T>(T, Nullable<String>)
Appends the specified path segment
to the builder's
Path and returns the same builder instance.
If the existing path ends with a single slash, or if the segment
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 segment
starts with multiple slashes, one slash is removed, but the rest are kept.
One additional slash gets added between the two parts in any case.
Declaration
public static T AppendPath<T>(this T builder, string? segment)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | segment | The segment to be appended to the builder's path. This can be null. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
AppendQueryParameter<T>(T, KeyValuePair<Nullable<String>, Nullable<String>>[], parameters)
Formats the specified parameters consisting of a key and value into
a set of query parameters (similar to &key=value
) and appends them at the
end of the Query string.
If the query ends with or if the final parameters starts with one or
more "&"
characters, they are trimmed, so that there is only a single
"&"
between the old query and the new parameters.
Declaration
public static T AppendQueryParameter<T>(this T builder, params KeyValuePair<string? , string? >[], parameters)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
KeyValuePair<Nullable<String>, Nullable<String>>[] | ||
parameters |
Returns
Type | Description |
---|---|
T | The specified |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
AppendQueryParameter<T>(T, Nullable<IEnumerable<KeyValuePair<Nullable<String>, Nullable<String>>>>)
Formats the specified parameters consisting of a key and value into
a set of query parameters (similar to &key=value
) and appends them at the
end of the Query string.
If the query ends with or if the final parameters starts with one or
more "&"
characters, they are trimmed, so that there is only a single
"&"
between the old query and the new parameters.
Declaration
public static T AppendQueryParameter<T>(this T builder, IEnumerable<KeyValuePair<string? , string? >>? parameters)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<IEnumerable<KeyValuePair<Nullable<String>, Nullable<String>>>> | parameters | A set of query parameters consisting of a key and value which should be appended to the query. This can be null. |
Returns
Type | Description |
---|---|
T | The specified |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
AppendQueryParameter<T>(T, Nullable<IEnumerable<(Nullable<String> Key, Nullable<String> Value)>>)
Formats the specified parameters consisting of a key and value into
a set of query parameters (similar to &key=value
) and appends them at the
end of the Query string.
If the query ends with or if the final parameters starts with one or
more "&"
characters, they are trimmed, so that there is only a single
"&"
between the old query and the new parameters.
Declaration
public static T AppendQueryParameter<T>(this T builder, IEnumerable<(string? Key, string? Value)>? parameters)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<IEnumerable<ValueTuple<Nullable<String>, Nullable<String>>>> | parameters | A set of query parameters consisting of a key and value which should be appended to the query. This can be null. |
Returns
Type | Description |
---|---|
T | The specified |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
AppendQueryParameter<T>(T, Nullable<String>)
Appends the specified parameter
at the end of the
Query.
If the query ends with or if the 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 T AppendQueryParameter<T>(this T builder, string? parameter)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | parameter | The query parameter to be appended to the query. This can be null. If so (or if empty), nothing gets appended. |
Returns
Type | Description |
---|---|
T | The specified |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
AppendQueryParameter<T>(T, Nullable<String>, Nullable<String>)
Formats the specified key
and value
into
a query parameter (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 T AppendQueryParameter<T>(this T builder, string? key, string? value)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | key | The key of the query parameter. This can be null. If so, it is treated as an empty string. If both |
Nullable<String> | value | The value of the query parameter. This can be null. If so, it is treated as an empty string. If both |
Returns
Type | Description |
---|---|
T | The specified |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
AppendQueryParameter<T>(T, (Nullable<String> Key, Nullable<String> Value)[], parameters)
Formats the specified parameters consisting of a key and value into
a set of query parameters (similar to &key=value
) and appends them at the
end of the Query string.
If the query ends with or if the final parameters starts with one or
more "&"
characters, they are trimmed, so that there is only a single
"&"
between the old query and the new parameters.
Declaration
public static T AppendQueryParameter<T>(this T builder, params (string? Key, string? Value)[], parameters)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
ValueTuple<Nullable<String>, Nullable<String>>[] | ||
parameters |
Returns
Type | Description |
---|---|
T | The specified |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SetFragment<T>(T, Nullable<String>)
Sets the Fragment property to the specified
fragment
and returns the same builder instance.
Declaration
public static T SetFragment<T>(this T builder, string? fragment)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | fragment | The optional fragment of the Uri which is being built. This can be null. If so, Fragment will be set to an empty string. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
SetHost<T>(T, Nullable<String>)
Sets the Host property to the specified
host
and returns the same builder instance.
Declaration
public static T SetHost<T>(this T builder, string? host)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | host | The optional host of the Uri which is being built. This can be null. If so, Host will be set to an empty string. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
SetPassword<T>(T, Nullable<String>)
Sets the Password property to the specified
password
and returns the same builder instance.
Declaration
public static T SetPassword<T>(this T builder, string? password)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | password | The optional password of the Uri which is being built. This can be null. If so, Password will be set to an empty string. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
SetPath<T>(T, Nullable<String>)
Sets the Path property to the specified
path
and returns the same builder instance.
Declaration
public static T SetPath<T>(this T builder, string? path)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | path | The path of the Uri which is being built. This can be null. If so, Path
will be set to a single slash |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
SetPort<T>(T, Nullable<Int32>)
Sets the Port property to the specified
port
and returns the same builder instance.
Declaration
public static T SetPort<T>(this T builder, int? port)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<Int32> | port | The optional port of the Uri which is being built. This can be null. If so, Port will be set to -1, indicating that no port information is available. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
SetQuery<T>(T, Nullable<String>)
Sets the Query property to the specified
query
and returns the same builder instance.
Declaration
public static T SetQuery<T>(this T builder, string? query)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | query | The optional query of the Uri which is being built. This can be null. If so, Query will be set to an empty string. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
SetScheme<T>(T, Nullable<String>)
Sets the Scheme property to the specified
scheme
and returns the same builder instance.
Declaration
public static T SetScheme<T>(this T builder, string? scheme)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | scheme | The scheme of the Uri which is being built. This can be null. If so, Scheme will be set to an empty string. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |
SetUserName<T>(T, Nullable<String>)
Sets the UserName property to the specified
userName
and returns the same builder instance.
Declaration
public static T SetUserName<T>(this T builder, string? userName)
where T : UriBuilder
Parameters
Type | Name | Description |
---|---|---|
T | builder | The builder. |
Nullable<String> | userName | The optional user name of the Uri which is being built. This can be null. If so, UserName will be set to an empty string. |
Returns
Type | Description |
---|---|
T | The same UriBuilder instance. |
Type Parameters
Name | Description |
---|---|
T | The UriBuilder type. |