Class
UrlBuilder
Provides a way to build URLs by adding segments, queries, and other components.
public sealed class UrlBuilderInheritance #
Inherited Members #
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors #
| Name | Description |
|---|---|
| UrlBuilder() | Initializes a new instance of the UrlBuilder class. |
| UrlBuilder(string) | Initializes a new instance of the UrlBuilder class from a URI string. |
Properties #
| Name | Description |
|---|---|
| Authority | Gets or sets the authority part of the URL. |
| Fragment | Gets or sets the fragment part of the URL. |
| NormalizeSeparators | Gets or sets a value indicating whether to normalize separators in the URL. |
| PathSeparator | Gets or sets the character used as the path separator. |
| Query | Gets the query parameters as an array of key-value pairs. |
| Scheme | Gets or sets the scheme part of the URL. |
| Segments | Gets the URL segments as an array of strings. |
| Uri | Gets the constructed URL as a Uri object. |
| Url | Gets the constructed URL as a string. |
Methods #
| Name | Description |
|---|---|
| AddQuery(string, string?) | Adds a query parameter to the URL. |
| AddQuery(string, params string?[]) | Adds a query parameter with multiple values to the URL. |
| AddQueryIf(string, string?[], bool) | Conditionally adds a query parameter with multiple values to the URL. |
| AddSegment(string?[], bool) | Adds one or more segments to the URL path. |
| AddSegment(params string?[]) | Adds one or more segments to the URL path. |
| AddSegment(string?) | Adds a single segment to the URL path. |
| AddSegmentIf(string, bool) | Conditionally adds a segment to the URL path. |
| ClearQuery() | Clears all query parameters from the URL. |
| ClearSegments() | Clears all segments from the URL path. |
| FromCombined(params string[]) | Creates a new UrlBuilder instance from one or more combined URLs and/or paths. |
| Pop(int) | Removes the last segment(s) from the URL path. |
| RemoveQuery(string) | Removes a query parameter from the URL. |
| SetAuthority(string) | Sets the authority part of the URL. |
| SetFragment(string?) | Sets the fragment part of the URL. |
| SetPathSeparator(char) | Sets the path separator character. |
| SetQuery(string, params string?[]) | Sets (removes and adds) a query parameter with multiple values in the URL. |
| SetQuery(string, string?) | Sets (removes and adds) a query parameter with a single value in the URL. |
| SetQueryIf(bool, string, string?) | Conditionally sets (removes and adds) a query parameter with a single value in the URL. |
| SetQueryIf(bool, string, params string?[]) | Conditionally sets (removes and adds) a query parameter with multiple values in the URL. |
| SetScheme(string) | Sets the scheme part of the URL. |
| ToString() | |
| TransformSegments(Func<string, string?>) | Applies a transformation function to each URL segment. |