ReqRest
Show / Hide Table of Contents

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.

Inheritance
Object
UriBuilder
UrlBuilder
Implements
IBuilder
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
  • uri

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
  • uri

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 builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

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 builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

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 builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

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 builder.

Implicit(UrlBuilder to Nullable<Uri>)

Implicitly converts the specified builder to an Uri by returning the value of the Uri property.

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 builder is null.

Exceptions
Type Condition
UriFormatException

The URI constructed by the UriBuilder properties is invalid.

Implements

IBuilder

Extension Methods

BuilderExtensions.Configure<T>(T, Action<T>)
BuilderExtensions.If<T>(T, Boolean, Action<T>)
BuilderExtensions.IfNot<T>(T, Boolean, Action<T>)
UriBuilderExtensions.SetScheme<T>(T, Nullable<String>)
UriBuilderExtensions.SetUserName<T>(T, Nullable<String>)
UriBuilderExtensions.SetPassword<T>(T, Nullable<String>)
UriBuilderExtensions.SetHost<T>(T, Nullable<String>)
UriBuilderExtensions.SetPort<T>(T, Nullable<Int32>)
UriBuilderExtensions.SetPath<T>(T, Nullable<String>)
UriBuilderExtensions.SetQuery<T>(T, Nullable<String>)
UriBuilderExtensions.SetFragment<T>(T, Nullable<String>)
UriBuilderExtensions.AppendPath<T>(T, Nullable<String>)
UriBuilderExtensions.AppendQueryParameter<T>(T, (Nullable<String> Key, Nullable<String> Value)[], parameters)
UriBuilderExtensions.AppendQueryParameter<T>(T, KeyValuePair<Nullable<String>, Nullable<String>>[], parameters)
UriBuilderExtensions.AppendQueryParameter<T>(T, Nullable<IEnumerable<(Nullable<String> Key, Nullable<String> Value)>>)
UriBuilderExtensions.AppendQueryParameter<T>(T, Nullable<IEnumerable<KeyValuePair<Nullable<String>, Nullable<String>>>>)
UriBuilderExtensions.AppendQueryParameter<T>(T, Nullable<String>, Nullable<String>)
UriBuilderExtensions.AppendQueryParameter<T>(T, Nullable<String>)
Back to top Copyright © 2019 ReqRest - Generated with DocFX - Material Theme made by Oscar Vásquez - Impressum (Imprint)