public async Task <ApplicationMenu> GetAsync(string name) { var menu = new ApplicationMenu(name); using (var scope = _serviceProvider.CreateScope()) { var context = new MenuConfigurationContext(menu, scope.ServiceProvider); foreach (var contributor in _options.MenuContributors) { await contributor.ConfigureMenuAsync(context); } } return(menu); }
public async Task <ApplicationMenu> GetAsync(string name) { var menu = new ApplicationMenu(name); using (var scope = ServiceScopeFactory.CreateScope()) { var context = new MenuConfigurationContext(menu, scope.ServiceProvider); foreach (var contributor in Options.MenuContributors) { await contributor.ConfigureMenuAsync(context).ConfigureAwait(false); } } NormalizeMenu(menu); return(menu); }
public async Task <ApplicationMenu> GetAsync(string name) { var menu = new ApplicationMenu(name); using (var scope = ServiceScopeFactory.CreateScope()) { RequirePermissionsSimpleBatchStateChecker <ApplicationMenuItem> .Instance.ClearCheckModels(); var context = new MenuConfigurationContext(menu, scope.ServiceProvider); foreach (var contributor in Options.MenuContributors) { await contributor.ConfigureMenuAsync(context); } await CheckPermissionsAsync(scope.ServiceProvider, menu); } NormalizeMenu(menu); return(menu); }
protected virtual async Task <ApplicationMenu> GetInternalAsync(string name) { var menu = new ApplicationMenu(name); using (var scope = ServiceScopeFactory.CreateScope()) { using (RequirePermissionsSimpleBatchStateChecker <ApplicationMenuItem> .Use(new RequirePermissionsSimpleBatchStateChecker <ApplicationMenuItem>())) { var context = new MenuConfigurationContext(menu, scope.ServiceProvider); foreach (var contributor in Options.MenuContributors) { await contributor.ConfigureMenuAsync(context); } await CheckPermissionsAsync(scope.ServiceProvider, menu); } } NormalizeMenu(menu); return(menu); }
public MenuConfigurationContext(ApplicationMenu menu, IServiceProvider serviceProvider) { Menu = menu; ServiceProvider = serviceProvider; }
protected virtual void NormalizeMenu(ApplicationMenu menu) { //TODO: Should also consider sub menus, recursively, bottom to top! menu.Items.RemoveAll(item => item.IsLeaf && item.Url.IsNullOrEmpty()); }
protected virtual void NormalizeMenu(ApplicationMenu menu) { menu.Items.RemoveAll(item => item.IsLeaf && item.Url.IsNullOrEmpty()); }
public MenuConfigurationContext(ApplicationMenu menu, IServiceProvider serviceProvider) { Menu = menu; ServiceProvider = serviceProvider; _lazyServiceProvider = ServiceProvider.GetRequiredService <IAbpLazyServiceProvider>(); }
public static ApplicationMenuItem GetAdministration(this ApplicationMenu applicationMenu) { return(applicationMenu.GetMenuItem(DefaultMenuNames.Application.Main.Administration)); }