Skip to content

Commit 062679b

Browse files
committed
refactor: 移除 RouteTabFactory 老代码
1 parent f120ef6 commit 062679b

File tree

1 file changed

+0
-41
lines changed

1 file changed

+0
-41
lines changed

src/BootstrapBlazor/Router/RouteTableFactory.cs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,6 @@
88
namespace BootstrapBlazor.Components;
99

1010
[ExcludeFromCodeCoverage]
11-
#if NET5_0
12-
internal static class RouteTableFactory
13-
{
14-
[NotNull]
15-
private static Microsoft.AspNetCore.Components.Routing.IRouteTable? Routes { get; set; }
16-
private static readonly HashSet<Assembly> _assemblies = new();
17-
18-
/// <summary>
19-
///
20-
/// </summary>
21-
/// <param name="assemblies"></param>
22-
/// <param name="url"></param>
23-
/// <returns></returns>
24-
public static RouteContext Create(IEnumerable<Assembly>? assemblies, string url)
25-
{
26-
RefreshRouteTable(assemblies);
27-
if (url.IndexOf("?") > 0) url = url[..url.IndexOf("?")];
28-
var routeContext = new Microsoft.AspNetCore.Components.Routing.RouteContext(url);
29-
Routes.Route(routeContext);
30-
return new RouteContext()
31-
{
32-
Handler = routeContext.Handler,
33-
Parameters = routeContext.Parameters,
34-
Segments = routeContext.Segments
35-
};
36-
}
37-
38-
private static void RefreshRouteTable(IEnumerable<Assembly>? assemblies)
39-
{
40-
assemblies ??= Enumerable.Empty<Assembly>();
41-
var assembliesSet = new HashSet<Assembly>(assemblies);
42-
if (!_assemblies.SetEquals(assembliesSet))
43-
{
44-
Routes = Microsoft.AspNetCore.Components.Routing.RouteTableFactory.Create(assemblies);
45-
_assemblies.Clear();
46-
_assemblies.UnionWith(assembliesSet);
47-
}
48-
}
49-
}
50-
#else
5111
internal static class RouteTableFactory
5212
{
5313
[NotNull]
@@ -85,4 +45,3 @@ private static void RefreshRouteTable(IEnumerable<Assembly> assemblies)
8545
}
8646
}
8747
}
88-
#endif

0 commit comments

Comments
 (0)