public async Task ListsFeatures()
        {
            IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton(config)
            .AddFeatureManagement()
            .AddFeatureFilter <ContextualTestFilter>();

            using (ServiceProvider provider = serviceCollection.BuildServiceProvider())
            {
                IFeatureManager featureManager = provider.GetRequiredService <IFeatureManager>();

                bool hasItems = false;

                await foreach (string feature in featureManager.GetFeatureNamesAsync())
                {
                    hasItems = true;

                    break;
                }

                Assert.True(hasItems);
            }
        }
示例#2
0
 private async Task LogFeatureFlags()
 {
     await
     foreach (var f in _featureManager.GetFeatureNamesAsync())
     {
         _logger.LogInformation($"Feature flags: {f} = {await _featureManager.IsEnabledAsync(f)}");
     }
 }
示例#3
0
        public async Task <IActionResult> GetFeatureAvailability(string name)
        {
            if (!await _featureManager.GetFeatureNamesAsync().AnyAsync(m => m == name))
            {
                return(NotFound(false));
            }

            return(Ok(await _featureManager.IsEnabledAsync(name)));
        }
        /// <inheritdoc />
        public async IAsyncEnumerable <string> GetFeatureNamesNotInFeatureEnumAsync()
        {
            var featureKeys = Enum.GetValues(typeof(TFeature)).Cast <TFeature>().Select(f => f.ToString()).ToList();

            await foreach (var featureName in _featureManager.GetFeatureNamesAsync())
            {
                if (!featureKeys.Contains(featureName))
                {
                    yield return(featureName);
                }
            }
        }
示例#5
0
        public async Task <ActionResult <IEnumerable <FeatureFlag> > > GetFeatureFlags()
        {
            List <FeatureFlag> features = new List <FeatureFlag>();

            await foreach (string feature in _featureManager.GetFeatureNamesAsync())
            {
                bool isEnabled = await _featureManager.IsEnabledAsync(feature);

                features.Add(new FeatureFlag {
                    Name = feature, isEnabled = isEnabled
                });
            }

            return(Ok(features));
        }
        public async IAsyncEnumerable <string> GetFeatureNamesAsync()
        {
            if (_featureNames == null)
            {
                var featureNames = new List <string>();

                await foreach (string featureName in _featureManager.GetFeatureNamesAsync().ConfigureAwait(false))
                {
                    featureNames.Add(featureName);
                }

                _featureNames = featureNames;
            }

            foreach (string featureName in _featureNames)
            {
                yield return(featureName);
            }
        }
 public ActionResult <IAsyncEnumerable <string> > GetFeatureNames()
 {
     return(Ok(_featureManager.GetFeatureNamesAsync()));
 }
示例#8
0
 public IAsyncEnumerable <string> GetFeatureNamesAsync()
 {
     return(_baseFeatureManager.GetFeatureNamesAsync());
 }