Table of Contents

Class ResourceUrlHelpers

Namespace
Acuit.Pinpoint.ResourceManagement
Assembly
Acuit.Pinpoint.ResourceManagement.Abstractions.dll

Helpers for working with resource URLs.

public static class ResourceUrlHelpers
Inheritance
ResourceUrlHelpers
Inherited Members

Methods

FormatUrl(string, params string[])

Formats a URL that specifies an absolute path to a resource, without an authority or query information.

public static Uri FormatUrl(string schemeName, params string[] segments)

Parameters

schemeName string

The scheme.

segments string[]

The path segments.

Returns

Uri

The Uri for the formatted URL.

Examples

var uri = ResourceUrlHelpers.FormatUrl("com.contoso.pinpoint", "testparameters", "MODEL1234");

Will yield a Uri for: com.contoso.pinpoint:/testparameters/MODEL1234

Exceptions

ArgumentNullException

schemeName is null.

ArgumentNullException

segments is null.

FormatUrl(string, string[], string)

Formats a URL that specifies an absolute path to a resource, without an authority, with query information.

public static Uri FormatUrl(string schemeName, string[] segments, string query)

Parameters

schemeName string

The scheme.

segments string[]

The path segments.

query string

The query information (without the leading '?').

Returns

Uri

The Uri for the formatted URL.

Examples

var uri = ResourceUrlHelpers.FormatUrl("com.contoso.pinpoint", "testparameters", "MODEL1234");

Will yield a Uri for: com.contoso.pinpoint:/testparameters/MODEL1234

Exceptions

ArgumentNullException

schemeName is null.

ArgumentNullException

segments is null.

ArgumentNullException

query is null.

TryParseUrl(Uri, string, string, int, out string[])

Tries to parse a resource URL that specifies an absolute path to a resource with a specific root segment optionally followed by a certain number of additional segments, and without an authority or query information.

public static bool TryParseUrl(Uri url, string schemeName, string rootSegment, int additionalSegmentCount, out string[] segments)

Parameters

url Uri

The URL.

schemeName string

The expected scheme. This is compared ignoring case.

rootSegment string

The expected root segment. This is compared ignoring case.

additionalSegmentCount int

The number of expected additional segments.

segments string[]

When this method returns, the array of path segments, including the root segment, upon success, or null if unsuccessful.

Returns

bool

true if url was successfully parsed; otherwise, false.

Exceptions

ArgumentNullException

url is null.

ArgumentNullException

schemeName is null.

ArgumentNullException

rootSegment is null.

ArgumentOutOfRangeException

additionalSegmentCount is less than zero.

TryParseUrl(Uri, string, string, int, out string[], out string)

Tries to parse a resource URL that specifies an absolute path to a resource with a specific root segment optionally followed by a certain number of additional segments, without an authority, and with optional query information.

public static bool TryParseUrl(Uri url, string schemeName, string rootSegment, int additionalSegmentCount, out string[] segments, out string query)

Parameters

url Uri

The URL.

schemeName string

The expected scheme. This is compared ignoring case.

rootSegment string

The expected root segment. This is compared ignoring case.

additionalSegmentCount int

The number of expected additional segments.

segments string[]

When this method returns, the array of path segments, including the root segment, upon success, or null if unsuccessful.

query string

When this method returns, the query information, or null if unsuccessful.

Returns

bool

true if url was successfully parsed; otherwise, false.

Exceptions

ArgumentNullException

url is null.

ArgumentNullException

schemeName is null.

ArgumentNullException

rootSegment is null.

ArgumentOutOfRangeException

additionalSegmentCount is less than zero.