Created
September 21, 2017 07:45
-
-
Save wallymathieu/61d1bc9d824fceca0c75f772b6995f3d to your computer and use it in GitHub Desktop.
Sample combine URI in c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace Namespace | |
| { | |
| /// <summary> | |
| /// Uri helpers | |
| /// </summary> | |
| public static class Uris | |
| { | |
| /// <summary> | |
| /// Create a new Uri based on base uri and relative path | |
| /// </summary> | |
| public static Uri Create(string baseUri, string relativePath)=> | |
| Uri.TryCreate(new Uri(baseUri), relativePath, out var combinedUri) | |
| ? combinedUri | |
| : throw new Exception($"Could not combine base uri : {baseUri} with relative path: {relativePath}"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment