コード例 #1
0
        public BackendMenuViewModel Create()
        {
            List <BackendMenuGroupViewModel> backendMenuGroupViewModels = new List <BackendMenuGroupViewModel>();

            foreach (IBackendMetadata backendMetadata in ExtensionManager.GetInstances <IBackendMetadata>())
            {
                if (backendMetadata.BackendMenuGroups != null)
                {
                    foreach (BackendMenuGroup backendMenuGroup in backendMetadata.BackendMenuGroups)
                    {
                        List <BackendMenuItemViewModel> backendMenuItemViewModels = new List <BackendMenuItemViewModel>();

                        foreach (BackendMenuItem backendMenuItem in backendMenuGroup.BackendMenuItems)
                        {
                            if (this.RequestHandler.HttpContext.User.Claims.Any(c => backendMenuItem.PermissionCodes.Any(pc => string.Equals(c.Value, pc, StringComparison.OrdinalIgnoreCase)) || string.Equals(c.Value, "DoEverything", StringComparison.OrdinalIgnoreCase)))
                            {
                                backendMenuItemViewModels.Add(new BackendMenuItemViewModelFactory(this.RequestHandler).Create(backendMenuItem));
                            }
                        }

                        BackendMenuGroupViewModel backendMenuGroupViewModel = this.GetBackendMenuGroup(backendMenuGroupViewModels, backendMenuGroup);

                        if (backendMenuGroupViewModel.BackendMenuItems != null)
                        {
                            backendMenuItemViewModels.AddRange(backendMenuGroupViewModel.BackendMenuItems);
                        }

                        backendMenuGroupViewModel.BackendMenuItems = backendMenuItemViewModels.OrderBy(bmi => bmi.Position);
                    }
                }
            }

            return(new BackendMenuViewModel()
            {
                BackendMenuGroups = backendMenuGroupViewModels.Where(bmg => bmg.BackendMenuItems.Count() != 0).OrderBy(bmg => bmg.Position)
            });
        }
コード例 #2
0
        public BackendMenuViewModel Create()
        {
            List <BackendMenuGroupViewModel> backendMenuGroupViewModels = new List <BackendMenuGroupViewModel>();

            foreach (IExtension extension in ExtensionManager.Extensions)
            {
                if (extension is Platformus.Infrastructure.IExtension)
                {
                    if ((extension as Platformus.Infrastructure.IExtension).BackendMetadata != null && (extension as Platformus.Infrastructure.IExtension).BackendMetadata.BackendMenuGroups != null)
                    {
                        foreach (Platformus.Infrastructure.BackendMenuGroup backendMenuGroup in (extension as Platformus.Infrastructure.IExtension).BackendMetadata.BackendMenuGroups)
                        {
                            List <BackendMenuItemViewModel> backendMenuItemViewModels = new List <BackendMenuItemViewModel>();

                            foreach (Platformus.Infrastructure.BackendMenuItem backendMenuItem in backendMenuGroup.BackendMenuItems)
                            {
                                backendMenuItemViewModels.Add(new BackendMenuItemViewModelFactory(this.handler).Create(backendMenuItem));
                            }

                            BackendMenuGroupViewModel backendMenuGroupViewModel = this.GetBackendMenuGroup(backendMenuGroupViewModels, backendMenuGroup);

                            if (backendMenuGroupViewModel.BackendMenuItems != null)
                            {
                                backendMenuItemViewModels.AddRange(backendMenuGroupViewModel.BackendMenuItems);
                            }

                            backendMenuGroupViewModel.BackendMenuItems = backendMenuItemViewModels.OrderBy(bmi => bmi.Position);
                        }
                    }
                }
            }

            return(new BackendMenuViewModel()
            {
                BackendMenuGroups = backendMenuGroupViewModels.OrderBy(bmg => bmg.Position)
            });
        }