-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathIndex.razor
More file actions
39 lines (33 loc) · 1.04 KB
/
Index.razor
File metadata and controls
39 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@page "/"
@using System.Reflection
@using System.Text.RegularExpressions
<div>
<nav>
<ul>
@foreach (var (name, url) in GetExperimentPages())
{
<li><a href=@(url)>@(name)</a></li>
}
</ul>
</nav>
</div>
@code {
/// <summary>Enumerates all .razor components in this folder</summary>
public IEnumerable<(string Name, string Url)> GetExperimentPages()
{
var routableComponents = Assembly
.GetExecutingAssembly()
.ExportedTypes
.Where(t => t.IsSubclassOf(typeof(ComponentBase)))
.Where(c => c
.GetCustomAttributes(inherit: true)
.OfType<RouteAttribute>()
.Count() > 0);
foreach (var routableComponent in routableComponents)
{
string name = routableComponent.ToString().Replace("ExperimentConfigTest.Pages.", string.Empty);
if (name != "Index")
yield return (name, name);
}
}
}