Table of Contents

Class UriExtensions

Namespace
TypedRest
Assembly
TypedRest.dll

Provides extension methods for System.Uri.

public static class UriExtensions
Inheritance
object
UriExtensions

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 uri, string relativeUri)

Parameters

uri Uri
relativeUri string

The relative URI to resolve. Add a ./ prefix here to imply a trailing slash in uri 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 uri, Uri relativeUri)

Parameters

uri Uri
relativeUri Uri

The relative URI to resolve. Add a ./ prefix here to imply a trailing slash in uri 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"));