Created
February 2, 2021 01:49
-
-
Save jdluzen/92c0ed4409a06350019bc0711acd2777 to your computer and use it in GitHub Desktop.
Parse the route attribute names out of route templates e.g. /main/view/{id}
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
private static IEnumerable<string> GetRouteParameters(RouteAttribute route) | |
{ | |
for (int i = 0; i < route.Template.Length; i++) | |
{ | |
if (route.Template[i] != '{') | |
continue; | |
i++; | |
for (int j = i; j < route.Template.Length; j++) | |
{ | |
if (route.Template[j] != '}') | |
continue; | |
else | |
{ | |
yield return route.Template[i..j]; | |
i = j; | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment