private static ConcurrentDictionary <string, PageMetadataModel> GenerateListOfPageMetadata( PageMetadataSettings settings ) { var pageList = new Dictionary <string, PageMetadataModel>(); var pageFileNameList = new List <string>(); // Get All Pages var pageMetadataList = settings.PageAssemblyList .SelectMany(x => x.DefinedTypes) .Where(type => typeof(PageMetadata).IsAssignableFrom(type)); foreach (var typeInfo in pageMetadataList) { if (Attribute.IsDefined( typeInfo, typeof(PageAttribute), false )) { var pageAttribute = typeInfo.GetCustomAttribute <PageAttribute>(); var routeAttribute = typeInfo.GetCustomAttribute <RouteAttribute>(); pageFileNameList.Add( typeInfo.Name ); if (routeAttribute == null) { throw new SystemException( $"Page Metadata needs a RouteAttribute to function: {typeInfo.Name}" ); } var metadataFileName = $"{typeInfo.Name}.razor.json"; var model = new PageMetadataModel { Title = typeInfo.Name, }; // If has the PageMetadata Attribute pull data from that first if (Attribute.IsDefined( typeInfo, typeof(PageMetadataAttribute) )) { var pageMetadataAttribute = typeInfo.GetCustomAttribute <PageMetadataAttribute>(); model.Title = pageMetadataAttribute?.Title ?? string.Empty; } model.Route = routeAttribute.Template; pageList.Add( routeAttribute.Template, model ); } } return(new ConcurrentDictionary <string, PageMetadataModel>( pageList )); }
public StandardPageMetadataRepository( PageMetadataSettings settings ) { _map = GenerateListOfPageMetadata( settings ); _nav = BuildPageNavigation( _map ); }