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
Returns
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
stringThe scheme.
segments
string[]The path segments.
query
stringThe query information (without the leading '?').
Returns
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
UriThe URL.
schemeName
stringThe expected scheme. This is compared ignoring case.
rootSegment
stringThe expected root segment. This is compared ignoring case.
additionalSegmentCount
intThe 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
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
UriThe URL.
schemeName
stringThe expected scheme. This is compared ignoring case.
rootSegment
stringThe expected root segment. This is compared ignoring case.
additionalSegmentCount
intThe 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
stringWhen this method returns, the query information, or null if unsuccessful.
Returns
Exceptions
- ArgumentNullException
url
is null.- ArgumentNullException
schemeName
is null.- ArgumentNullException
rootSegment
is null.- ArgumentOutOfRangeException
additionalSegmentCount
is less than zero.