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); } }
private async Task LogFeatureFlags() { await foreach (var f in _featureManager.GetFeatureNamesAsync()) { _logger.LogInformation($"Feature flags: {f} = {await _featureManager.IsEnabledAsync(f)}"); } }
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); } } }
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())); }
public IAsyncEnumerable <string> GetFeatureNamesAsync() { return(_baseFeatureManager.GetFeatureNamesAsync()); }