コード例 #1
0
        private async Task InitRouteTable()
        {
            var apps = AdditionalAssemblies == null ? new[] { Assembly.GetEntryAssembly() } : new[] { Assembly.GetEntryAssembly() }.Concat(AdditionalAssemblies).Where(a => a != null);
            var componentTypes = apps.SelectMany(a => a !.ExportedTypes.Where(t => typeof(IComponent).IsAssignableFrom(t)));

            foreach (var componentType in componentTypes)
            {
                var routeAttributes = componentType.GetCustomAttributes <RouteAttribute>(false);
                foreach (var template in routeAttributes.Select(t => t.Template))
                {
                    RouteTable.TryAdd(template.Trim('/'), componentType);
                }
            }
            Navigator.LocationChanged += Navigator_LocationChanged;

            await InvokeAsync(() => AddTabByUrl(Navigator.ToBaseRelativePath(Navigator.Uri)));
        }