Table of Contents

Class UriExtensions

Namespace
TypedRest
Assembly
TypedRest.dll

Provides extension methods for Uri.

public static class UriExtensions
Inheritance
UriExtensions
Inherited Members

Methods

EnsureTrailingSlash(Uri)

Adds a trailing slash to the URI if it does not already have one.

public static Uri EnsureTrailingSlash(this Uri uri)

Parameters

uri Uri

Returns

Uri

ExtractCredentials(Uri)

Extracts credentials from user info in URI if set.

public static NetworkCredential? ExtractCredentials(this Uri uri)

Parameters

uri Uri

Returns

NetworkCredential

Join(Uri, string)

Resolves a relative URI using this URI as the base.

public static Uri Join(this Uri baseUri, string relativeUri)

Parameters

baseUri Uri

The base URI to resolve from.

relativeUri string

The relative URI to resolve. Prepend ./ to imply a trailing slash in baseUri even if it is missing there.

Returns

Uri

Examples

Debug.Assert(new Uri("http://myhost/path").Join("./subpath") == new Uri("http://myhost/path/subpath"));

Join(Uri, Uri)

Resolves a relative URI using this URI as the base.

public static Uri Join(this Uri baseUri, Uri relativeUri)

Parameters

baseUri Uri

The base URI to resolve from.

relativeUri Uri

The relative URI to resolve. Prepend ./ to imply a trailing slash in baseUri even if it is missing there.

Returns

Uri

Examples

Debug.Assert(new Uri("http://myhost/path").Join(new Uri("./subpath", UriKind.Relative)) == new Uri("http://myhost/path/subpath"));