public async Task <ActionResult> Features() { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageFeatures)) // , T["Not allowed to manage features."] { return(Unauthorized()); } //var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate(); var shellDescriptor = await _shellDescriptorManager.GetShellDescriptorAsync(); var availableFeatures = await _featureManager.GetAvailableFeaturesAsync(); IEnumerable <ModuleFeature> features = availableFeatures .Where(f => !DefaultExtensionTypes.IsTheme(f.Extension.ExtensionType)) .Select(f => new ModuleFeature { Descriptor = f, IsEnabled = shellDescriptor.Features.Any(sf => sf.Name == f.Id), //IsRecentlyInstalled = _moduleService.IsRecentlyInstalled(f.Extension), //NeedsUpdate = featuresThatNeedUpdate.Contains(f.Id), DependentFeatures = _moduleService.GetDependentFeatures(f.Id).Where(x => x.Id != f.Id).ToList() }) .ToList(); return(View(new FeaturesViewModel { Features = features, IsAllowed = ExtensionIsAllowed })); }
public async Task <IEnumerable <FeatureEntry> > GetEnabledFeatureEntriesAsync() { //TODO 这里终究要实现 IShellFeatureManager 代替 var shell = await _shellDescriptorManager.GetShellDescriptorAsync(); var enabledFeatureIds = new HashSet <string>(shell.Features.Select(x => x.Id)); var allFeatures = await _extensions.LoadFeaturesAsync(); return(allFeatures.Where(x => enabledFeatureIds.Contains(x.FeatureInfo.Id))); }
/// <summary> /// Retrieves an enumeration of the available features together with its state (enabled / disabled). /// </summary> /// <returns>An enumeration of the available features together with its state (enabled / disabled).</returns> public async Task <IEnumerable <ModuleFeature> > GetAvailableFeatures() { var currentShellDescriptor = await _shellDescriptorManager.GetShellDescriptorAsync(); var enabledFeatures = currentShellDescriptor.Features; return(_extensionManager.AvailableExtensions() .SelectMany(m => _extensionManager.LoadFeatures(m.Features)) .Select(f => AssembleModuleFromDescriptor(f, enabledFeatures .FirstOrDefault(sf => string.Equals(sf.Name, f.Descriptor.Id, StringComparison.OrdinalIgnoreCase)) != null))); }
public async Task <ActionResult> Features() { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageFeatures)) // , T["Not allowed to manage features."] { return(Unauthorized()); } //var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate(); var shellDescriptor = await _shellDescriptorManager.GetShellDescriptorAsync(); var availableFeatures = _extensionManager.GetExtensions().Features; var moduleFeatures = new List <ModuleFeature>(); foreach (var moduleFeatureInfo in availableFeatures.Where(f => !f.Extension.Manifest.IsTheme())) { var dependentFeatures = await _moduleService.GetDependentFeaturesAsync(moduleFeatureInfo.Id); var moduleFeature = new ModuleFeature { Descriptor = moduleFeatureInfo, IsEnabled = shellDescriptor.Features.Any(sf => sf.Id == moduleFeatureInfo.Id), //IsRecentlyInstalled = _moduleService.IsRecentlyInstalled(f.Extension), //NeedsUpdate = featuresThatNeedUpdate.Contains(f.Id), DependentFeatures = dependentFeatures.Where(x => x.Id != moduleFeatureInfo.Id).ToList() }; moduleFeatures.Add(moduleFeature); } return(View(new FeaturesViewModel { Features = moduleFeatures, IsAllowed = ExtensionIsAllowed })); }
/// <summary> /// Retrieves the enabled features. /// </summary> /// <returns>An enumeration of feature descriptors for the enabled features.</returns> public async Task <IEnumerable <FeatureDescriptor> > GetEnabledFeaturesAsync() { var currentShellDescriptor = await _shellDescriptorManager.GetShellDescriptorAsync(); return(_extensionManager.EnabledFeatures(currentShellDescriptor)); }
private void UpdateShell() { var descriptor = _shellDescriptorManager.GetShellDescriptorAsync().Result; _shellDescriptorManager.UpdateShellDescriptorAsync(descriptor.SerialNumber, descriptor.Features, descriptor.Parameters).Wait(); }
private Task <ShellDescriptor> GetCurrentShell() { return(_shellDescriptorManager.GetShellDescriptorAsync()); }