Last active
July 31, 2021 16:03
-
-
Save AngelMunoz/dcc4a909a1b08c2060e802e9c187c140 to your computer and use it in GitHub Desktop.
This file contains 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
open System.IO | |
// each case is kind of a "label" | |
// active patterns are limited to 7 choices though so keep that in mind | |
let (|IsNet50|Else|EndsWithSlash|) (path: string) = | |
if path.EndsWith("net5.0") then | |
IsNet50 | |
else if path.EndsWith('/')then | |
EndsWithSlash | |
else Else path | |
let basePath = | |
// use the pattern matching against a string | |
let path = Path.GetFullPath "." | |
match path with | |
| IsNet50 -> Path.GetFullPath "../../../" | |
| EndsWithSlash -> path.[.. path.Length - 1] | |
| Else path -> path | |
// if you wanted to add more cases, you would need to add more labels to the active pattern | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment