Beispiel #1
0
        public async Task <object> List([FromQuery] string keyword)
        {
            // 这里需要加特殊权限,只允许Default的管理员可访问
            var enabledFeatures = await _engineFeaturesManager.GetEnabledFeaturesAsync();

            var moduleFeatures = new List <FeatureModel>();

            foreach (var moduleFeatureInfo in _pluginManager.GetFeatures().ToList())
            {
                moduleFeatures.Add(new FeatureModel()
                {
                    Descriptor   = moduleFeatureInfo,
                    Enabled      = enabledFeatures.Contains(moduleFeatureInfo),
                    Dependencies = _pluginManager.GetDependentFeatures(moduleFeatureInfo.Id).Where(d => d.Id != moduleFeatureInfo.Id).ToList()
                });
            }
            var query = moduleFeatures.AsQueryable();

            if (!string.IsNullOrEmpty(keyword))
            {
                query = query.Where(e => e.Descriptor.Name.Contains(keyword) || e.Descriptor.Id.Contains(keyword));
            }
            return(new
            {
                List = query.GroupBy(e => !string.IsNullOrEmpty(e.Descriptor.Category) ? e.Descriptor.Category : "其他")
                       .Select(e => new FeatureGroupModel()
                {
                    Category = e.Key,
                    Features = e
                }).ToList(),
                Total = moduleFeatures.Count
            });
        }
Beispiel #2
0
        private IEnumerable <IFeatureInfo> GetFeaturesToDisable(IFeatureInfo featureInfo, bool force)
        {
            var affectedFeatures = _pluginManager
                                   .GetDependentFeatures(featureInfo.Id)
                                   .ToList();

            if (affectedFeatures.Count > 1 && !force)
            {
                if (_logger.IsEnabled(LogLevel.Warning))
                {
                    _logger.LogWarning("Additional features need to be disabled.");
                }
                if (FeatureDependencyNotification != null)
                {
                    FeatureDependencyNotification("If {0} is disabled, then you'll also need to disable {1}.", featureInfo, affectedFeatures.Where(f => f.Id != featureInfo.Id));
                }
            }

            return(affectedFeatures);
        }