in src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationOptions.cs [271:313]
public AzureAppConfigurationOptions UseFeatureFlags(Action<FeatureFlagOptions> configure = null)
{
FeatureFlagOptions options = new FeatureFlagOptions();
configure?.Invoke(options);
if (options.RefreshInterval < RefreshConstants.MinimumFeatureFlagRefreshInterval)
{
throw new ArgumentOutOfRangeException(nameof(options.RefreshInterval), options.RefreshInterval.TotalMilliseconds,
string.Format(ErrorMessages.RefreshIntervalTooShort, RefreshConstants.MinimumFeatureFlagRefreshInterval.TotalMilliseconds));
}
if (options.FeatureFlagSelectors.Count() != 0 && options.Label != null)
{
throw new InvalidOperationException($"Please select feature flags by either the {nameof(options.Select)} method or by setting the {nameof(options.Label)} property, not both.");
}
if (options.FeatureFlagSelectors.Count() == 0)
{
// Select clause is not present
options.FeatureFlagSelectors.Add(new KeyValueSelector
{
KeyFilter = FeatureManagementConstants.FeatureFlagMarker + "*",
LabelFilter = string.IsNullOrWhiteSpace(options.Label) ? LabelFilter.Null : options.Label,
IsFeatureFlagSelector = true
});
}
foreach (KeyValueSelector featureFlagSelector in options.FeatureFlagSelectors)
{
_selectors.AppendUnique(featureFlagSelector);
_ffWatchers.AppendUnique(new KeyValueWatcher
{
Key = featureFlagSelector.KeyFilter,
Label = featureFlagSelector.LabelFilter,
Tags = featureFlagSelector.TagFilters,
// If UseFeatureFlags is called multiple times for the same key and label filters, last refresh interval wins
RefreshInterval = options.RefreshInterval
});
}
return this;
}